<jQuery> < methods > 18. Remove events, trigger events, event objects (block bubbling, block jumps)

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Title</title></Head><Body><P>Raylee</P><P>Raylee</P><P>Raylee</P><inputtype= "button"value= "Trigger"ID= "BTN"><inputtype= "button"value= "Event Object"ID= "BTN1"><ahref= "Http://www.baidu.com"ID= "link">Jump</a><Scriptsrc= "Jquery-3.2.1.js"></Script><Script>    $(function () {        //Registering Events        $("P"). On ("Click", function() {alert ("hehe");        }); //Remove All Events        //$ ("P"). Off ();        //Triggering Events        //$ ("#btn"). Click (function () {        //$ ("P"). Click ();        //$ ("P"). Trigger ("click");        // })        //Event object, E is the event object        $("#btn1"). On ("Click", function(e) {console.log (e);        }); //prevent bubbles and prevent browser from default behavior        $("#link"). On ("Click", function(e) {alert ("AAA"); //Block JumpE.preventdefault (); //Stop bubblinge.stoppropagation (); })        $("#link"). On ("Click", function(e) {alert ("BBB");    }); });</Script></Body></HTML>

<jQuery> < methods > 18. Remove events, trigger events, event objects (block bubbling, block jumps)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.