例如,我有这段html代码:
.....
<span class="no"> 1</span> require <span class="s"><span class="dl">'</span><span class="k">yaml</span><span class="dl">'</span></span>
<span class="no"> 2</span> require <span class="s"><span class="dl">'</span><span class="k">set</span><span class="dl">'</span></span>
<span class="no"> 3</span>
<span class="no"> 4</span> <span class="r">module</span> <span class="cl">ActiveRecord</span> <span class="c">#:nodoc:</span>
<span class="no"> 5</span> <span class="c"># Generic Active Record exception class.</span>
<span class="no"> 6</span> <span class="r">class</span> <span class="cl">ActiveRecordError</span> < <span class="co">StandardError</span>
<span class="no"> 7</span> <span class="r">end</span>
.....
然后我在Firefox和Chrome浏览器中运行这个jQuery代码:
$('.no')[0]
在Chrome中我有:
<span class="no"> 1</span>
但在Firefox中,我还没有完整的元素:
<span class="no">
这种差异真的让我的项目变得混乱,请解释我为什么以及如何避免这个问题。感谢
答案 0 :(得分:5)
这可能只是firebug或chrome调试器显示它的方式。你尝试过像
那样的事吗?alert ( $('.no')[0].html() );