2012-07-02 174 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正在尝试瞄准第二个... –

相关问题