Wednesday 15 August 2012

jquery - JavaScript Getting Images Ids In Form -



jquery - JavaScript Getting Images Ids In Form -

i have images in form , want each images ids javascript ,i have code not work.

html codes;

<form id="form1"> <img src="..." id="img1"> <img src="..." id="img2"> <img src="..." id="img3"> </form>

javascript codes;

var image=$("form [id='form1']").find('img'); var i0=image[0].attr('id'); var i1=image[1].attr('id'); .........

how can each images id's in form?

thanks.

try this

var arr = []; $('#form1 img').each(function(i, v){ arr.push($(this).attr('id')) }) console.log(arr);

javascript jquery html

No comments:

Post a Comment