Home > Web Front-end > JS Tutorial > body text

JavaScript enhanced custom callback example_javascript skills

WBOY
Release: 2016-05-16 17:21:57
Original
1235 people have browsed it

html:

Copy code The code is as follows:



js:
Copy code code As follows:

$().ready(function(){
$("select").unbind("clickMe");
//Pass a json format object, this There are name, age, callback in json, which can be accessed using objJSON. attribute name
$("select").bind("clickMe", function(event,objJSON){
alert(objJSON. name);
alert(objJSON.age);
objJSON.callback();
});

$("select").unbind("change");
$("select").bind("change",function(){
//The parameter of the event trigger is an object in json format
$(this).trigger("clickMe",{
name:'xxc',
age:20,
callback:function(){
alert("callback function");
}
});
}) ;
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!