【问题标题】:Scroll to specific line number with syntaxHighlighter使用 syntaxHighlighter 滚动到特定的行号
【发布时间】:2017-04-13 20:05:45
【问题描述】:

i have a div panel, when i click on a button it shows up, with scroller on position 0 on lines number "gutter"

i have a highlight line on line 200 and 201 as shown

<pre class="brush: php;highlight:[24,25,28,29,30,200,201]; toolbar: false;">

               <?php

             $html = file_get_contents("index.php");
             echo htmlspecialchars($html);
              ?>

               </pre>

编辑:问题是我无法抓取数字线,因为它属于语法荧光笔插件 源代码来自另一个文件(file_get_contents...)

当我单击按钮以显示我的面板时,我想自动滚动到第 201 行....这可能吗?我到处寻找解决方案都是徒劳的,你能帮帮我吗?

【问题讨论】:

  • 你能分享你到目前为止所做的事情吗?

标签: javascript jquery css syntaxhighlighter


【解决方案1】:

如果您突出显示该行,我认为您可以在代码中获取该行元素。然后您可以将窗口滚动到该元素:

var line = $(/*your highlighted line*/);
var offset = line.offset();
window.scrollTo(offset.left, offset.top);

【讨论】:

  • @BendimeradAdelReda,我的回答有帮助还是你还在为它而苦恼?
猜你喜欢
  • 2018-11-15
  • 1970-01-01
  • 2010-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-16
  • 1970-01-01
相关资源
最近更新 更多