Trigger and Triggerhandler are both simulated events, with specific cases to describe the difference
Copy Code code as follows:
<meta charset= "Utf-8" >
<title>test</title>
<script src= "Http://code.jquery.com/jquery-1.10.2.js" ></script>
<body>
<input type= "checkbox"/>
<input type= "text" id= "test"/>
<input type= "button" value= "button" id= "BNT" onclick= "Bntclick ()"/>
</body>
<script>
$ (document). Ready (function () {
$ ("input[type= ' checkbox ']"). Bind ("click", Function () {
$ ("#test"). Val ("www.baidu.com");
});
});
function Bntclick () {
$ ("input[type= ' checkbox ']"). Trigger ("click");
}
</script>
When the checkbox is clicked, the checkbox is ticked and the input[type= ' text ' is assigned www.baidu.com
The same thing happens when you click on the Input[type= ' button ' and click the checkbox
Replace trigger with Triggerhandler when clicking input[type= ' button ' will only assign value to input[type= ' text ' without checking checkbox
Triggerhandler The default behavior of elements that block bound events