Sunday, February 19, 2012

Toggle element JQuery

I don't who code this snippet but i like it :-)
(I also know there is the toggle function from JQuery)

Togger = function (e) {
    // Show the paragraph if it's hidden.
    var $paragraph = $(;
    var $link = $(this);
    if ($':hidden')) {
      $link.text('Click to hide');
    // Hide the paragraph if it's visible.
    else {
      $link.text(' Click to show');

$('#toggle-link-1').bind('click','#paragraph-1', Togger);
$('#toggle-link-2').bind('click','#paragraph-2', Togger);

No comments:

Post a Comment