Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browse/iterate each input element of a div

Tags:

jquery

<div id="arraydiffid">
    <input type="hidden" name="array_diff[]" value="0" />
    <input type="hidden" name="array_diff[]" value="1" />
    <input type="hidden" name="array_diff[]" value="2" />
    <input type="hidden" name="array_diff[]" value="3" />

    <div class='hello'>
        somethings
    </div

    <input type="hidden" name="array_diff[]" value="4" />

    <span>hello</span>

    <input type="hidden" name="array_diff[]" value="5" />        
</div>

How can I browse only all "input type hidden" children? (and not the rest, as div or span) I tried :

$('#arraydiffid>children').each(function(){
    alert($(this).value());
}); 
like image 503
markzzz Avatar asked Feb 26 '23 21:02

markzzz


1 Answers

$('#arraydiffid > input[type=hidden]').each(function() {

    if($(this).val()>=param) 
       $(this).val($(this).val()+1);
});

Hope that helps :)

like image 195
Gazillion Avatar answered Mar 07 '23 23:03

Gazillion