2010-12-09 126 views
0
$(this).siblings("property2").hide().child("select").attr("disabled","disabled"); 

這是應該訪問單擊按鈕的同級「property2」並隱藏它。之後,它將訪問「property2」的孩子「選擇」並添加一個禁用的屬性「選擇」。有人可以告訴我這個腳本有什麼問題

但這不起作用。請幫助...謝謝!

+1

能否請您上傳您的HTML這裏.. – 2010-12-09 05:28:28

+1

是property2一類? – Stephen 2010-12-09 05:30:12

回答

0

假設property2是一個類,而選擇是該元素的直系後裔:

$(this) 
    .siblings('.property2') 
    .hide() 
    .children("select") 
    .attr("disabled","disabled"); 
0
$(this).siblings(".property2").hide().children().attr("disabled","disabled"); 

做到了... ^^

1
$(this).siblings(".property2").hide().children("select").attr("disabled","disabled"); 
  1. child應替換爲children()

如果您使用的是property2,那麼您試圖選擇標籤名稱爲property2的元素。如果你想通過classname訪問,那麼它將是.property2

如果你想刪除disabled屬性,那麼你可以使用.removeAttr("disabled")

相關問題