Use jquery to simultaneously control the scalable implementation code for four pictures _jquery

Source: Internet
Author: User
Tags tagname
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<style type= "Text/css" >
. imgclass
{
height:200px;
width:200px;
}
. imgclass1
{
width:210px; height:210px;
}
Table TR TD
{
width:250px; height:250px;
}
</style>
<script src= "Jquery-1.9.1.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #Button1 '). Click (function () {
Gets the elements of all types (tagname) as img
$ (' img '). Show (3000);
$ (' img '). Hide (3000);
Gets the element with the value "Imgclass" for all class attributes
$ ('. Imgclass '). Hide (3000);
$ ('. Imgclass '). Show (3000);
$ ("#img1, #img2, #Button1"). Hide (2000);
$ ("#img1, #img2, #Button1"). Show (2000); It must be surrounded by a pair of "all IDs" instead of each ID enclosed in quotes
Multiple selectors can be either an ID or a mixture of id,tagname and classname
$ ("#img1, #img2, input"). Hide (2000);
$ ("#img1, #img2, Input"). Show (2000);
Change the style of a picture
$ (' #Button2 '). Click (function () {
$ (' #img2 '). Removeclass ()//delete class style with ID Img2
$ (' #img2 '). addclass (' Imgclass1 ');//Then add a style, click the button again to manipulate the picture, because the style of this picture has changed, so do not change
})
})
})
</script>
<body>
<table>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td>
<input id= "Button1" type= "button" value= "Dot Me"/></td></tr>
<tr><td></td><td> <input id= "Button2" type= "button" value= "Change control style"/></td></ Tr>
</table>
</body>

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.