Js mouse click event and other capturing

Source: Internet
Author: User

<Div> <a href = "#" onclick = "showPricediv ('aaa')" abc = 1> adsfsdf </a> </div>
<Div id = "aaa" style = "display: none "onmouseover =" temshowTag = true "onmouseout =" temshowTag = false "> <pricediv> <table> <tr> <td> dfdfsdf </td> </tr> </ table> </pricediv> </div>
<Div> <a href = "#" onclick = "showPricediv ('div1 ')" abc = 1> adsfsdf </a> </div>
<Div id = "Div1" style = "display: none "onmouseover =" temshowTag = true "onmouseout =" temshowTag = false "> dfdfdf <br/> <pricediv> dfdfdfdf </pricediv> </div>
<Div> <a href = "#" onclick = "showPricediv ('div2')" abc = 1> adsfsdf </a> </div>
<Div id = "Div2" style = "display: none "onmouseover =" temshowTag = true "onmouseout =" temshowTag = false "> <pricediv> dfdfdf <br/> dfdfdfdf </pricediv> </div>
</Body>
<Script>
Var temEventobject = null;
Var temshowTag = false;
Function document. onclick ()
{
If (event. srcElement. abc = null & temshowTag = false)
{
Var temabc = document. getElementsByTagName ("pricediv ");
For (I = 0; I <temabc. length; I ++)
{
Temabc [I]. parentElement. style. display = "none ";
}
}
}
Function showPricediv ()
{
Document. getElementById (a). style. display = "";
TemEventobject = document. getElementById ();
TemshowTag = true;
}
</Script>
This code is used to open a div by clicking a button and clicking the mouse in the blank area of the page to hide this div
Function document. onclick ()
{
}
In this way, you can override the events or methods of a built-in object, but only the document and window are allowed. Similarly, You can override events or methods such as alert.

Related Article

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.