jquery Learning (ii) Selector

Source: Internet
Author: User

This is an example of an application of selectors:

When you click the "get the last div CSS class name" This input, you should pay attention to the various circumstances of the class name change.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>jquery selector </title>
<style>
. change{
Background-color: #009900;
}
. border{
border: #FF0000 thin solid;
}
</style>
<script language= "javascript" type= "Text/javascript" src= ". /jquery-1.2.6.min.js "></script>
<script language= "JavaScript" >
function Change1 ()
{
var meinv=$ ("div");

for (Var i=1;i<meinv.length;i=i+2)
{
Meinv[i].classname= "Change";
}
}
function Change2 ()
{
var meinv=$ ("div");

for (Var i=1;i<meinv.length;i=i+2)
{
Meinv[i].classname= "";
}
}
function Change3 () {
var getclass=$ ("Div:last");
$ ("span"). Text (Getclass.attr ("class"));
}
function Change4 ()
{
$ ("DIV:GT (1)"). AddClass ("border");
}
function Change5 ()
{
$ ("DIV:GT (1)"). Removeclass ("border");
}
function Change6 ()
{
$ ("INPUT:GT (1)"). attr ("Disabled", "disabled");
}

</script>

<body>
<div><a href= "http://www.gooddo.com%22%3ewww.gooddo.com/can't go out and order curtains </a></div>
<div> high-grade taste, convenient and fast, save time and effort, and worry! </div>
<div><a href= "http://www.gooddo.com%22%3ewww.gooddo.com/can't go out and order curtains </a></div>
<div> high-grade taste, convenient and fast, save time and effort, and worry! </div>
<div><a href= "http://www.gooddo.com%22%3ewww.gooddo.com/can't go out and order curtains </a></div>
<div> high-grade taste, convenient and fast, save time and effort, and worry! </div>
<p>
<input name= "D" type= "button" onclick= "Change6 ()" value= "Lock back Input"/>
<input name= "D" type= "button" onclick= "Change1 ()" value= "de-interlace"/>
<input name= "D" type= "button" onclick= "Change2 ()" value= "Cancel interlacing"/>
<input name= "D" type= "button" onclick= "Change3 ()" value= "gets the CSS class name of the last div"/>
<input name= "D" type= "button" onclick= "Change4 ()" value= "for second div plus border"/>
<input name= "D" type= "button" onclick= "Change5 ()" value= "remove second div border"/>
</p>
<span></span>
</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.