javascript - Use first $(this) in second forEach() -


i've been looking on web issue i'm facing..

i can't find way use, in second nested loop, first $(this). php aliases ?

does knows if it's possible ?

you can see code below represent problem.

$(".btn-labeled").click(function() {   var uid = $(this).parent().prev("td").html();   $.get( "?what="+uid, function( data ) {   var parsedjson =  json.parse(data);    $(".rule").each(function()   {     var serviceaccount = $(this).children("td").html();     parsedjson.foreach(function(iteration)     {       if(iteration["service_account"] != serviceaccount)       {         //i want attached first loop :p         $(this).children("td").next("td").children("div").children("input").removeattr("checked");       }     });    });       }); }); 

thanks in advance

create variable element reference in inner loop:

$(".btn-labeled").click(function() {   var uid = $(this).parent().prev("td").html();   $.get( "?what="+uid, function( data ) {   var parsedjson =  json.parse(data);    $(".rule").each(function()   {    var element = $(this);//here     var serviceaccount = $(this).children("td").html();     parsedjson.foreach(function(iteration)     {       if(iteration["service_account"] != serviceaccount)       {        element.children("td").next("td").children("div").children("input").removeattr("checked");       }     });    });       }); }); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -