I'm trying to write a click
function to select the next g.slice
node, add a class of .sliceActive
to it and remove .sliceActive
from the original .slice
. However, only when you are at the last g.slice
(with a class of .slice5
) you would add the .sliceActive
to the the first g.slice
with a class of .slice0
.
This is what I have so far that is not working. I think the problem is I don't know how to see if the current .sliceActive
node also has the class of .slice5
.
$(".next").click(function(){
var nextSlice;
if(d3.select("g.sliceActive").hasClass("slice5")){
nextSlice= d3.select(".slice0");
}else{
nextSlice= d3.select("g.sliceActive + g");
}
d3.select("g.sliceActive").classed("sliceActive",false);
nextSlice.classed("sliceActive",true);
});
And here is how it looks in the web inspector: