我有一個搜索按鈕。點擊搜索按鈕時,就會產生這樣的代碼:從jquery循環div中獲得隱藏值
<div class = 'clickedResult' title = 'click to see details'>
<table>the result will br written in this table </table>
<input type = 'hidden' class = 'form_id' value = '$form_id' />
<input type = 'hidden' class = 'status' value = '$status' />
</div> <br/>
這段代碼中循環,循環去兩次循環的結果是這樣的
<div class = 'clickedResult' title = 'click to see details'>
<table>the result will br written in this table </table>
<input type = 'hidden' class = 'form_id' value = '14' />
<input type = 'hidden' class = 'status' value = 'latest' />
</div>
<div class = 'clickedResult' title = 'click to see details'>
<table>the result will br written in this table </table>
<input type = 'hidden' class = 'form_id' value = '48' />
<input type = 'hidden' class = 'status' value = 'updated' />
</div>
如果表中的一個被點擊,它會做這(使用jQuery)
$(".clickedResult").click(function()
{
$('.clickedResult input.form_id').each(function()
{
alert($(this).val());
});
});
它會提醒14和48 ...如何,如果我單擊第一個表中只有14警示?如果我點擊第二個表,它會提醒48?
非常感謝你..它的工作原理 –