View / repeat each input element div

<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 view only all β€œhidden” input types? (and not the rest, like a div or span) I tried:

 $('#arraydiffid>children').each(function(){ alert($(this).value()); }); 
+4
source share
2 answers
 $('#arraydiffid > input[type=hidden]').each(function() { if($(this).val()>=param) $(this).val($(this).val()+1); }); 

Hope that helps :)

+8
source

It might be useful to wrap them in a form, as it is assumed that the input should be displayed. Then you can use jQuery.serialize to access the data.

 <form id="arraydiffid> <input /> .... </form> $("#arraydiffid").serialize(); //array_diff%5B%5D=0&array_diff.... 

I cannot speed up writing in a pseudo-array, I believe that the way you configure your inputs, you will need the jQuery plugin to use these notations.

http://api.jquery.com/serialize/ Example: http://jsfiddle.net/N7ZC4/

0
source

All Articles