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>