keskiviikko 27. tammikuuta 2016

jQuery tricks Toggle HTML Element Change

I struggled so much about changing element with jQuery and I finally after few hours of searching found a little hack to do this so I wanted to share it with everyone.

First create two html elements with same classname, but add display:none to other element like this:

  <span class="trick">Open</span>
  <span class="trick" style="display:none;">Closed</span>

Then with jQuery just do

  $('.trick').toggle();

And super, the element is toggling!

Ei kommentteja:

Lähetä kommentti