2013-06-12 44 views
0

我有兩個div。jquery檢索元素沒有某種類

<div dpath="somepath" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> 
<div dpath="anotherpath" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"> 

我想得到沒有類'ui-tabs-hide'的div對象。我曾嘗試過:

var tab = $('.ui-tabs-panel').not('.ui-tabs-hide'); 

這是行不通的。

+1

這應該工作。當您嘗試選擇它時,該元素是否已經具有所有類? *嘗試選擇這些元素後,jQuery插件可能會被初始化。 –

+0

mhhh,那應該工作。你可以添加更多的代碼? –

+0

似乎工作正常http://jsfiddle.net/j08691/mN9Va/ – j08691

回答

1

你的代碼的工作,只是你的HTML是無效的,你必須關閉div標籤:

http://jsfiddle.net/mGSsG/

<div dpath="somepath" class="ui-tabs-panel ui-widget-content ui-corner-bottom"></div> 
<div dpath="anotherpath" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"></div> 
+2

我認爲這只是HTML的一部分。沒有內容的標籤無論如何都沒有意義,是嗎?這比IMO的回答更具評論意義(如果沒有問題,那麼問題應該關閉)。 –

+0

@FelixKling雅,好點 –

0

你的代碼的工作,見下面的鏈接:

<div dpath="somepath" class="ui-tabs-panel ui-widget-content ui-corner-bottom">AAAAAAAAA</div> 
<div dpath="anotherpath" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">BBBBBBBBB</div> 

http://jsfiddle.net/sBWSq/