在JQueryMobile中,你可以这样做:
$(document).on("pagebeforehide","#pagetwo",function(){
alert("pagebeforehide event fired - pagetwo is about to be hidden");
});
这可以通过自定义事件进行吗?像这样:
document.addEventListener("someevent", "sometrigger", function () {});
答案 0 :(得分:1)
尝试
$(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>
&#13;
请参阅.trigger()