better implementation of on click toggle class jquery -


hello wondering if me out. have jquery code adds class specific divs in page. wondering if there better way implement code, because glitchy. have 5 div ids add visible class to. have 1 class applies div elements should toggle active class. new jquery , not sure if proper way implement it, please see code below:

$('.graph-button').click(function() {     $(this).toggleclass("active"); });      //get circles show text boxes adding class $('#value_button').click(function(){   $('#value_text').toggleclass("visible"); }); $('#history_button').click(function(){   $('#history_text').toggleclass("visible"); }); $('#vision_button').click(function(){   $('#vision_text').toggleclass("visible"); }); $('#offering_button').click(function(){   $('#offering_text').toggleclass("visible"); }); $('#future_button').click(function(){   $('#future_text').toggleclass("visible"); }); 

i appreciate help. cheers!

just toggle class of next element anytime button pressed

$('.graph-button').click(function() {     $(this).toggleclass("active");     $(this).next().toggleclass("visible"); });   

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -