Pertama, mari kita lihat model acara JS. Model acara JS menggelembung ke atas. Misalnya, setelah acara OnClick dipicu, acara akan mengikuti node untuk menyebar ke atas sampai acara klik terikat ke node induk. Jika tidak mencapai akar dokumen.
Untuk menghentikan gelembung: 1. Stoppropagation () untuk browser non -e. 2. Atribut Batalkan Batal adalah benar. Untuk browser yaitu,
JQuery sudah memiliki metode yang kompatibel dengan browser, event.stopimmediatePropagation ();
<! Doctype html> <html> <head> <meta charset = "utf-8"/> <script type = "text/javaScript" src = "js/jQuery-1.4.4.min.js"> </skrip> <title> </title> </head> <style> <style> type = "text/css"> body {background-color:#999999;}#myDiv {latar belakang-warna: #fffff; Lebar: 250px; tinggi: 250px; Tampilan: tidak ada; } </style> <body> <input id = "btn" type = "button" value = "show div"/> <div id = "myDiv"> Ini adalah div; </div> </body> <script type = "text/javascript" (calling ("#n (" #n ("#) (function () {() {() {() {() {() {() {() {() {() {() {() {() {() {() {function () {() {function () {() {() {() {function () {() {function () {functi () {function () Tampilkan metode div $ (dokumen) .one ("klik", function () {// Bind a Shadow Div Metode $ (myDiv) .hide ();}); event.stoppropagation (); // hentikan acara untuk menggelembung}); $ (myDiv) .klik (event) {event.stoppropagation {event) {event) {event) {event. function showDiv () {$ (myDiv) .fadein ();} </script>