HTML code
<script type= "Text/javascript" >
$ (function () {
$ ("#btn4"). Click (function () {
$ (#btn3). Click () ;
});
});
function Change () {
alert ("onclick");
}
</script>
<button id= "btn3" onclick= "Change ()" >dd</button>
<button id= "Btn4" >ee </button>
Difference:
1.onclick is the binding event that tells the browser what to do when the mouse clicks
The click itself is a method that triggers the onclick event, which triggers the onclick event whenever the element's click () method is executed. As the appeal code shows, clicking the ' EE ' button triggers the ' dd ' onclick event (normally the ' DD ' button triggers the ' dd ' onclick event), because
$ ("#btn4"). Click (function () {
$ ("#btn3"). Click ();
};
Clicking the ' EE ' button invokes the ' DD ' click () method inside the code, triggering the ' DD ' onclick event.
The primary role of the 2.click () method is to trigger the call to the click Method Element onclick event. Also, if the following code is defined in the click Method
$ ("#btn3"). Click (function () {
alert ("* * *");
});
The function code in the click Method executes after the OnClick event has finished executing, at which point the click Method acts as an append event. Examples are as follows
HTML code
<script type= "Text/javascript" >
$ (function () {
$ ("#btn3"). Click (function () {
alert ("AA");
})
;
function Change () {
alert ("BB");
}
</script>
<button id= "btn3" onclick= "Change ()" >dd</button>
The pop-up sequence is first ' BB ' and then ' AA '.