2009-09-24 48 views

回答

2

是的,無論標籤上有多少個類別,它都能正常工作。

1

是的,只要您知道它將爲每個設置了「.class2」的元素都綁定click事件,那就可以正常工作。

爲什麼?發生了什麼?

+0

好,我想我有一個bug其他地方,謝謝。 – mrblah 2009-09-24 21:47:22

0

我已經在IE8和Firefox 3.5.3中測試了你的代碼,並且它完美地工作。

如果它不適合你,那肯定還有其他原因。

1

元素上的多個類是有效的。下面應該舉例說明一些幫助理解JQuery類選擇器的例子。

<div class="class1">one</div> 
<div class="class2">two</div> 
<div class="class1 class2">three</div> 

然後

//will bind to the first and third div  
$(".class1").bind("click", ....); 

//will bind to the second and third driv 
$(".class2").bind("click", ....); 

//will bind to only the third div, you get only elements that have BOTH classes 
$(".class1.class2").bind("click", ....); 

//will bind to all divs, you get elements with class1 along with elements with class2 
$(".class1, .class2").bind("click", ....); 
相關問題