jquery - d3.js equivalent to $(this) -


i modify state of text node when clicked upon, apparently fail access correctly. when click, nothing happens (unless use jquery selector, , not command work). question is: d3.js equivalent $(this) ?

var buttons = svg.selectall(".button"); buttons.on("click",function(d){     var target = $(this).attr('target');     var visible  = $(this).attr('visible');     if(visible==='1'){         svg.selectall(".bar."+target)                 .transition()                 .duration(500)                 .ease("elastic")                 .style('display','none');     $(this).attr('visible','0')                 .style('text-decoration','line-through');     }else{         svg.selectall(".bar."+target)                     .transition()                     .duration(500)                     .ease("elastic")                     .style('display','inline');         $(this).attr('visible','1');         $(this).removeclass('active');     }         }); 

it turns out d3.select(this) correct answer.

code :

var buttons = svg.selectall(".button"); buttons.on("click",function(d){     var target = $(this).attr('target');     var visible  = $(this).attr('visible');     if(visible==='1'){         svg.selectall(".bar."+target).transition().duration(500).ease("elastic").style('display','none');         d3.select(this).attr('visible','0').style('text-decoration','line-through');       }else{         svg.selectall(".bar."+target).transition().duration(500).ease("elastic").style('display','inline');         d3.select(this).attr('visible','1').style('text-decoration','');     } }); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -