我的應用程序中有以下代碼。在兩個元素之間獲取文本JQUERY
<div title="Please Click Here to Expand" class="technology3 closedlanguage" headerindex="0h">
<span class="accordprefix">
<img src="http:www.test.com/expanded.gif" style="width:13px; height:13px; margin-Right:20px">
</span>
Need this text<span class="accordsuffix"></span></div>
我需要得到「accordprefix」和「accordsuffix」類,這是「極品本文」
爲了這個,我沒有下面的代碼之間的文本。
$(window).load(function(){
$(".accordprefix").each(function(){
alert($(this).next().html());
});
});
但它不工作。請給出任何建議。
因爲它沒有包裝在特定的對象中,所以它在'.accordprefix'範圍的父元素內。你可以做'$(「。accordprefix」)。each(function(){$(this).parent()。html();});'然後你需要過濾掉所有其他的HTML需要。 – Nunners
你有多個accordprefix和accordsuffix元素? –