2
我有這樣的HTML塊:幫助的jQuery選擇
<p><strong>this is the title</strong>this is the content</p>
我怎麼只有「這是內容」字符串使用jQuery?
謝謝:)
我有這樣的HTML塊:幫助的jQuery選擇
<p><strong>this is the title</strong>this is the content</p>
我怎麼只有「這是內容」字符串使用jQuery?
謝謝:)
試試這個:http://jsfiddle.net/mTn7G/
var text = $('p').contents().last().text();
的.contents()
方法獲取所有子元素,包括文本節點,而.last()
會給你最後一個,和.text()
將返回其文字內容。
非常感謝您的幫助! – alon 2010-09-08 00:45:57