2012-07-02 32 views
0

這是我的HTML代碼

<div id="list_refer_1"> 
    <form id="refer_1_0"> 
     <input type="hidden" name="channel" value="1"> 
     <input type="hidden" name="url" id="input_1_0" value="http://localhost:8000/"> 
     <input type="button" onclick="pullrefer(1, 0);" value=" - "> 
     http://localhost:8000/ 
    </form> 
    <form id="refer_1_xxxxx"> ///xxxxx is timestamp 
     <input type="hidden" name="channel" value="1"> 
     <input type="hidden" name="url" id="input_1_1" value="http://127.0.0.1:8000/"> 
     <input type="button" onclick="pullrefer(1, 1);" value=" - "> 
     http://127.0.0.1:8000/ 
    </form> 
    <form id="refer_1_2"> 
     <input type="hidden" name="channel" value="1"> 
     <input type="hidden" name="url" id="input_1_2" value="http://localhost*"> 
     <input type="button" onclick="pullrefer(1, 2);" value=" - "> 
     http://localhost* 
    </form> 
    ... 

我可以通過

$('#list_refer_1 #refer_1_0 input[name=url]').val(); 

,但我希望得到價值

$('input[name=url]').val() from $('#list_refer_1 **form**')**[1]**; 

HOWTO怎麼做呢? 謝謝。

回答

3

使用:eq()選擇(它是從零開始

$('#list_refer_1 form:eq(1) input[name=url]').val(); 
+0

@undefined,請不要不重要原因編輯帖子。(***值**的屬性值。既可以是一個**不加引號的單個單詞**或一個帶引號的字符串*) –

+0

非常感謝。^ _^ –

+0

@undefined,OP正在嘗試瞄準第二個... –

相關問題