check if a button is clicked or not in jquery

check if a button is clicked or not in jquery

This is most interesting topic 's jQuery, Here is two steps to check if is HTML element are clicked or not?

Step 1: In this step, we used the .data() method to set the data (true).

         Example.  $(this).data('clicked', true);

Step 2: In this step, we used the .data() method to get the data which are set.

         Example.  var data = $('#activeLogomain').data('clicked');


The detail code sample are give below.


<script type="text/javascript">
    $("#activeLogomain").click(function () {
        $(this).data('clicked'true);
    });

    if ($('#activeLogomain').data('clicked')) {

        $('.nav_menu li').each(function () {
            $(this).removeClass('active');
        });

        $('.nav_menu [id="MI_Dashboard"]').addClass('active');
    }

</script>
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.