jquery - Locate an element and change the class -


i trying change class of div divprintdetailed divprintselected

<div id= "maindiv" class ="maindiv">  <div id ="partialviewdiv">   <div class="ui-submenu"> </div>   <div id="reportcontainer" class="divprintdetailed"></div>  </div> </div> 

the following line of code doesn't job. doing wrong.

 $('#maindiv').find('div.divprintdetailed').attr('class', 'divprintselected'); 

try this:

demo both versions.

$('#maindiv').find('div.divprintdetailed').removeclass('divprintdetailed').addclass('divprintselected'); 

and change html maindiv has id:

<div id="maindiv" class ="maindiv"> 

you can use toggleclasse() like:

$('#maindiv').find('div.divprintdetailed,div.divprintselected').toggleclass('divprintdetailed divprintselected'); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -