2012-06-06 72 views
1

我有一個實例,我想要根據點擊更改文本和選擇框的狀態。jQuery - 啓用/禁用切換內的選擇框();

$("#foo").click(function(){ 

$("#mytext").toggle(); 
$(this).text($(this.text() == 'on' ? 'off' : 'on'); 
// here i also want to enable and disable a select box, not sure how to do this other then checking if the value of (this).text is on or off. 

}); 

非常感謝!

回答

5
var status = $(this).text(); 

$('#dropdownId').prop('disabled',status != 'on'); 
+0

感謝兄弟,這樣做:) –