JS and jquery bind an ID onclink event at the same time

Source: Internet
Author: User

Case code:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<title>shortLink</title>
<script src= "Http://localhost:8090/short_link/js/jquery/jquery-1.8.3.min.js" ></script>//the introduction of the jquery framework
<script type= "Text/javascript" >

$ (document). Ready (function () {
$ ("#test"). Click (function () {
Alert ("Hello");
});
$ ("#test"). Click (function () {
Alert ("Hello 2");
});
});
function dd () {
Alert ("dd!");
}
function dd () {
Alert ("DD2");
}
function aa () {
Alert ("aa!");
}
</script>
<body>
<input id= "test" type= "button" value= "OK" onclick= "DD (); AA ();" />
</body>

Corresponding results:

DD2 aa! Hello, hello. 2

Summarize:

See from the results;

1) JS multiple response events with the same name, only the last one will be executed

2) Onclink binds multiple events and executes in left-to-right order

3) jquery binding event multiple times, and will be executed after the JS event







JS and jquery bind an ID onclink event at the same time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.