JQuery .each Against a Variable -
how 1 specify target variable jquery each function? performing request , placing results in variable. want run each function on variable pull out id tags. many thanks.
$.get("somepage.php?id=45 #my_target_div", function(data) { $.each(function(data, "#id") { }); });
the $.get() method doesn't allow filter down results selector .load() does, , use of .each() wrong.
this allow loop through elements have id attribute inside my_target_div.
$.get("somepage.php?id=45", function(data) { $("<div />").html(data).find("#my_target_div [id]").each(function(){ // annoying alert alert(this.id); // or more appealing console log // console.log(this.id); }); });
Comments
Post a Comment