In JQueryMobile you can do this:
$(document).on("pagebeforehide","#pagetwo",function(){
alert("pagebeforehide event fired - pagetwo is about to be hidden");
});
Is this possible with custom events? Something like so:
document.addEventListener("someevent", "sometrigger", function () {});
Try
$(document).on("someevent", "div", function(e) { console.log(this.innerText) }); var elem = $("div:contains('abc')"); if (elem.length) { elem.trigger("someevent") };
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div>abc</div> <div>123</div>
See .trigger()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.