I want to make some clicks with Jquery dynamically onLoad of a page. I found how :
$("#pdt1").trigger("click");
I have part of the id into my session display into a string like that “1,3,7” and i want to generate some clicks like that :
$("#pdt1").trigger("click");
$("#pdt3").trigger("click");
$("#pdt7").trigger("click");
So i have write that in Jquery :
$(document).ready(function () {
//Getting my string of Ids
var mesId = $('#<%= selectedID.ClientID %>').val();
//Cut my string into an array
var subId = mesId.split(',');
//Send a click for each id
$(subId).each(function (event) {
$('#pdt'+ this).trigger("click");
});
});
And obviously, that don’t work. I am sure that i get my ids and cut them properly. What i’m not sure is about the each function, and the concatenation. Anyone know how make it work?
Thank you.
Try using
.eachlike below,