Skip to content

Instantly share code, notes, and snippets.

@zaimramlan
Last active September 12, 2016 02:21
Show Gist options
  • Select an option

  • Save zaimramlan/52ee349db03395dd671d8f147491128c to your computer and use it in GitHub Desktop.

Select an option

Save zaimramlan/52ee349db03395dd671d8f147491128c to your computer and use it in GitHub Desktop.
Create own HTML tag to hide element of the same class

Step 1: Add the following jQuery snippet to your JS file

$(function(){
    $("[data-hide]").on("click", function(){
        $("." + $(this).attr("data-hide")).hide();
    });
});

Step 2: Add data-hide=[CLASS_NAME] as attribute to any HTML tag to hide that element on click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment