2012-01-02 11 views
2

私のHTMLは次のとおりです。このHTMLの次の「選択」(ドロップダウン)を選択するにはどうすればよいですか?

<tr> 
     <td><select id = "delAppSelectApp" name="delAppSelectApp"><option value="--Select--"> --Select--</option></select></td> 
     <td><select id = "delAppSelectAppVers" name="delAppSelectAppVers"><option value="--Select--">--Select--</option></select></td> 
     <td><input type="submit" name="submitDelAppVers" id="submitDelAppVers" value="Delete Application Version" /></td> 
    </tr> 

私のスクリプトは次のとおりです。

$(document).ready(function(){ 
    $("#delAppSelectApp").change(function(){ 
     alert($(this).nextAll("select").attr("id")); 
    }); 
}); 

私は窓が起きていない "delAppSelectAppVers" を、警告します。私は間違って何をしていますか?私は "兄弟"機能を試してみました。ノードのXPath /軸内の同じレベルでは「次」の要素(兄弟)が存在しないので、それは働いていないhttp://jsfiddle.net/7twmJ/

答えて

3
$(document).ready(function() { 
    $("#delAppSelectApp").change(function() { 
     alert($(this).closest("td").next().find('select').attr("id")); 
    }); 
}); 

はここでデモです。試してみよう:

$(this).parent.next().children("select:first").attr("id") 
1

関連する問題