假設我有這樣的HTML標記的每一行:JQuery的:讀一個元素
<div id="wrapper">
<pre class="highlight">
$(function(){
// hide all links except for the first
$('ul.child:not(:first)').hide();
$("a.slide:first").css("background-color","#FF9900");
$('ul.parent a.slide').click(function(){
$('ul.parent a.slide').css("background-color","#3399FF");
$('ul.parent a.slide').mouseout(function(){
$(this).css("background-color","#3399FF");
});
$('ul.parent a.slide').mouseover(function(){
$(this).css("background-color","#66CC66");
});
});
});
</pre>
</div>
什麼是閱讀存在於DIV代碼的每一行的最簡單的方法。如何以任何我想要的方式從每個線樣式的div或循環中提取每行代碼。
感謝
編輯:
我已經包裝類後加入pre
標籤,請考慮之謂也。由於
我假設你在''wrapper'的CSS中有'white-space:pre'或其他什麼東西? – 2010-04-07 14:05:37
這是邪惡的最純粹的形式。 – googletorp 2010-04-07 14:11:55
@ T.J。克勞德:是的,我有。 – Sarfraz 2010-04-07 14:14:54