jcadima
3/23/2018 - 8:14 PM

Toggle content with button click


http://jsfiddle.net/j999y/3631/

=============== HTML =================
<button id="myelement">HIDE MY VIDEOS</button>
<p class="user_id_match">
  This is the paragraph to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>

<p class="">
  SHOWN 11 is the paragraph to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>

<p class="user_id_match">
  This is the 2222 to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>

<p class="">
  SHOWN 22 is the paragraph to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>

<p class="another_element">
  This is the 3333 to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>


========== JS ====================
$( "#myelement" ).click(function() {   
		$(this).text('SHOW MY VIDEOS');
    if($('.user_id_match:visible').length)
        $('.user_id_match').hide("slide", { direction: "right" }, 1000);
    else{
    $(this).text('HIDE MY VIDEOS');
        $('.user_id_match').show("slide", { direction: "right" }, 1000);        }
});