jquery-evnets

Special jQuery Events

When I thought of writing this post, I was actually confused about the title of the post but then I ended with “Some special jQuery Events“. If you know these events then they are not special for you but if you have come across them for the first time, then they are definitely special for you. So in this post, I will explain about 3 jQuery events. Which are,

  • one
  • trigger
  • toggle

one: Attach a handler to an event for the elements. The handler is executed at most once per element. In simple terms, the attached function will be called only once.

$(document).ready(function() {
    $("#btnDummy").one("click", function() {
        alert("This will be displayed only once.");
    });
});

In this case, when button is clicked for the first time, then only the alert will be displayed.

trigger: Execute all handlers and behaviors attached to the matched elements for the given event type. In simple terms, you can trigger or call other event using trigger event. For example, There are 2 buttons and from Button 1 click you want to call Button 2 click event. This you can achieve using trigger event.

$(document).ready(function() {
    $("#btnDummy1").bind("click", function() {
        alert("Button 1 is clicked");
        $('#btnDummy2').trigger('<wbr>click'); }); $("#btnDummy2").bind("click", function() { alert("Button 2 is clicked"); }); });

toggle: Bind two or more handlers to the matched elements, to be executed on alternate clicks. This is like on/off switch. When you on the switch fan starts and when you off fan stops.

$(document).ready(function() {
    $('#btnDummy').toggle(<wbr>function() { alert('First handler for .toggle() called.'); }, function() { alert('Second handler for .toggle() called.'); }); });


Feel free to contact me for any help related to jQuery, I will gladly help you.

Related Posts


19 thoughts on “Special jQuery Events

  1. kore dizileri izle

    Genuinely vital post admin great a single i bookmarked your world-wide-web webpage see you in up coming blog site publish.

    Reply
  2. Mimi du journal du jardin

    I would like to thank the author of this article so much because that’s exactly the informations I was looking for.

    Reply
  3. Gabriel Souliere

    I simply want to mention I am beginner to weblog and really loved your web page. Almost certainly I’m planning to bookmark your blog post . You absolutely have exceptional articles. Regards for sharing with us your blog.

    Reply
  4. Alise Benadom

    Thanks for your your content – really interesting. We love our Kindle and the best site for tips and tricks is coolkindles.

    Reply
  5. hotel promo jakarta

    Wow, that’s what I was seeking for, what a material! existing here at this web site, thanks admin of this web page.

    Reply
  6. Nestor Daskal

    There may be noticeably a bundle to learn about this. I assume you made sure nice factors in options also.

    Reply
  7. Roscoe Mendibles

    After study a couple of of the blog posts on your website now, and I really like your way of blogging. I bookmarked it to my bookmark website record and might be checking again soon. Pls try my website online as effectively and let me know what you think.

    Reply
  8. Mohammed Decarolis

    There’s noticeably a bundle to learn about this. I assume you made sure nice points in options also.

    Reply
  9. Lia Kniphfer

    Thanks a ton for this – love the info and agree with your perspective. However many others will not, so thanks for speaking up. Nice blog, well done!

    Reply
  10. Morton Ellstrom

    I just want to tell you that I am just beginner to blogging and certainly savored you’re web-site. Probably I’m likely to bookmark your blog . You definitely come with tremendous stories. Many thanks for sharing your webpage.

    Reply
  11. finanzierungsrechner auto

    Great info. Lucky me I came across your website
    by chance (stumbleupon). I have saved as a favorite for later!

    Reply
  12. Kari Ruck

    I think that is one of the so much important info for me. And i’m glad reading your article. But want to observation on some common things, The website taste is great, the articles is in point of fact great : D. Excellent task, cheers

    Reply
  13. Computer Store Winnipeg

    Super Sweet Blog U Have Here. Very Educational Subject For A Website Keep Up The Interesting Work!!. Check Out The Winnipeg Computer Repair Master Website And Tell Me What You Think!!!!

    Reply
  14. Kenneth Olmsted

    I love this web site, excellent information in here. Really good tips. Make sure you keep publishing such things.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


*