Border effect when jquery adds a cursor to an image

Source: Internet
Author: User

A buddy wants to add the border effect when the mouse passes through the image. Unfortunately, the starting point is wrong. It is directly added to the tag outside the IMG, causing the image to collapse when the mouse passes through, in fact, you should add the border control directly to the IMG label.
The error code is as follows: Pay attention to the red part settings (the starting point is wrong)
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript" src = "http://www.w3school.com.cn/jquery/jquery.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# Box a"). mouseover (function (){
Certificate (this).css ("border", "1px solid red ");
});
$ ("# Box a"). mouseout (function (){
Certificate (this).css ("border", "none ");
});
});
</Script>
<Style>
# Box a {display: block; z-index: 1000; width: 98px; height: 98px ;}
</Style>
</Head>
<Body>
<Div id = "box" style = "width: 100px; height: 100px;">
<A href = "#"> </a>
<A href = "#"> </a>
</Div>
</Body>
</Html>

Correct design concept after modification: The red part is the adjusted settings
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript" src = "http://www.w3school.com.cn/jquery/jquery.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# Box img"). mouseover (function (){
Certificate (this).css ("border", "1px solid red ");
});
$ ("# Box img"). mouseout (function (){
Certificate (this).css ("border", "none ");
});
});
</Script>
<Style>
# Box a {display: block; z-index: 1000; width: 98px; height: 98px ;}
</Style>
</Head>
<Body>
<Div id = "box" style = "width: 100px; height: 100px;">
<A href = "#"> </a>
<A href = "#"> </a>
</Div>
</Body>
</Html>

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.