jquery modifies the style under Li and the value of the IMG under Li's src _jquery

Source: Internet
Author: User

How jquery modifies the style under Li, and modifies the value of the IMG under Li's src, below is the specific implementation code that needs a friend to see

$ (". Test Li"). Click (function () {
$ (". Test Li a"). Removeclass ("test01");
$ (". Test Li a"). AddClass ("test02");
$ ("a", this). Removeclass ("test02");//A label in current Li
$ ("a", this). AddClass ("test01");
var Title_index = $ (this). Index ()//
all img
var allimg = $ (". Test li img")
in the index//li of the current Li; for (var i = 0; i < allimg.size (); i++) {
if (i% 2 = 0) {
$ (allimg[i]). attr ("src", "images/b04.gif"); Change im G's SRC
} else {

$ (allimg[i]). attr ("src", "images/b05.gif");
}
The current img
var IMGs = $ ("img", this) in Li;
for (var i = 0; i < imgs.size (); i++) {
if (i = = 0) {
$ (imgs[i]). attr ("src", "images/b01.gif");
{

$ (imgs[i]). attr ("src", "images/b02.gif");
}
if (Title_index = = 0) {
$ ("#a). Hide ();
$ ("#b"). Show ();
else {
$ (' #b '). Hide ();
$ ("#a"). Show ();
} 
}

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.