jQuery修改li下的样式,以及修改li下的img的src的值

news/2024/7/11 1:59:21 标签: jQuery, li, img, a
<article class="baidu_pl">
article_content" class="article_content clearfix">
ass="htmledit_views"> $(".test <a class="tags" href="/tags/LI.html" title=li>lia>").c<a class="tags" href="/tags/LI.html" title=li>lia>ck(function() {
an style="white-space:pre">an>$(".test <a class="tags" href="/tags/LI.html" title=li>lia> a").removeClass("test01");
an style="white-space:pre">an>$(".test <a class="tags" href="/tags/LI.html" title=li>lia> a").addClass("test02");
an style="white-space:pre">an>$("a", this).removeClass("test02");//当前<a class="tags" href="/tags/LI.html" title=li>lia>中的a标签
an style="white-space:pre">an>$("a", this).addClass("test01");
an style="white-space:pre">an>var title_index = $(this).index();//当前<a class="tags" href="/tags/LI.html" title=li>lia>的index
an style="white-space:pre">an>//<a class="tags" href="/tags/LI.html" title=li>lia>中所有的<a class="tags" href="/tags/IMG.html" title=img>imga>
an style="white-space:pre">an>var allImg = $(".test <a class="tags" href="/tags/LI.html" title=li>lia> <a class="tags" href="/tags/IMG.html" title=img>imga>");
an style="white-space:pre">an>for ( var i = 0; i < allImg.size(); i++) {
an style="white-space:pre">an>if (i % 2 == 0) {
an style="white-space:pre">an>$(allImg[i]).attr("src", "images/b04.gif");//改变<a class="tags" href="/tags/IMG.html" title=img>imga>的src
an style="white-space:pre">an>} else {


an style="white-space:pre">an>$(allImg[i]).attr("src", "images/b05.gif");
an style="white-space:pre">an>}
an style="white-space:pre">an>}
an style="white-space:pre">an>//当前<a class="tags" href="/tags/LI.html" title=li>lia>中的<a class="tags" href="/tags/IMG.html" title=img>imga>
an style="white-space:pre">an>var <a class="tags" href="/tags/IMG.html" title=img>imga>s = $("<a class="tags" href="/tags/IMG.html" title=img>imga>", this);
an style="white-space:pre">an>for ( var i = 0; i < <a class="tags" href="/tags/IMG.html" title=img>imga>s.size(); i++) {
an style="white-space:pre">an>if (i == 0) {
an style="white-space:pre">an>$(<a class="tags" href="/tags/IMG.html" title=img>imga>s[i]).attr("src", "images/b01.gif");
an style="white-space:pre">an>} else {


an style="white-space:pre">an>$(<a class="tags" href="/tags/IMG.html" title=img>imga>s[i]).attr("src", "images/b02.gif");
an style="white-space:pre">an>}


an style="white-space:pre">an>}
an style="white-space:pre">an>if (title_index == 0) {
an style="white-space:pre">an>$("#a).hide();
an style="white-space:pre">an>$("#b").show();
an style="white-space:pre">an>} else {
an style="white-space:pre">an>$("#b").hide();
an style="white-space:pre">an>$("#a").show();
an style="white-space:pre">an>} 
an style="white-space:pre">an>})
article>

http://www.niftyadmin.cn/n/1599598.html

相关文章

css中padding中样式的顺序含义

4种可能的情况&#xff0c;举例说明&#xff1a; padding:10px; 四个内边距都是10px padding:5px 10px;   上下5px 左右10px padding:5px 10px 15px; 上5px 右10px 下15px 左因为缺省与右相等&#xff0c;则为10px…

cf1406 C 树的重心

题意&#xff1a;https://www.luogu.com.cn/problem/CF1406C 思路&#xff1a;首先需要知道树的重心的一些性质&#xff0c;可以看看这篇文章 https://zhuanlan.zhihu.com/p/357938161 那么这题就是找出重心&#xff0c;如果有两个就将他的一个子树移到另一个重心上。 /*ke…

[Linux] 在windows下给命令起别名(alias)

最受不了的是windows下面没有"ls"命令。怎么办&#xff1f; 最简单的方法是写一个“ls.bat”放在windows目录下&#xff0c;内容为“dir”。 然后“ps”命令也是必不可少的&#xff1a;创建一个“ps.bat”&#xff0c;内容为“tasklist”&#xff0c;同样放在windows…

target属性值

有 4 个保留的目标名称用作特殊的文档重定向操作&#xff1a; _blank 浏览器总在一个新打开、未命名的窗口中载入目标文档。 _self 这个目标的值对所有没有指定目标的 <a> 标签是默认目标&#xff0c;它使得目标文档载入并显示在相同的框架或者窗口中作为源文档。这个目标…

[C++] 在windows下编译libevent 2.0

在下载的libevent里面是没有visual studio的项目文件的。编译起来比较麻烦。 下面是我整理的一个vcproj项目文件。需要的同学请另存为libevent-2.0.4-alpha.vcproj&#xff0c;放在“D:/project/libevent-2.0.4-alpha/libevent-2.0.4-alpha”目录下。 目录不一致的话自己修改…

sqlserver中的sql语句中1=2什么意思

12表示没有其它条件时不查出数据&#xff0c;用作where拼接sql句子

j = j++

public class Main { public static void main(String[] args) { int j 0; for(int i0; i<100; i) { j j; // j j; // 100 } System.out.println(j); } } j j 最后j 为0&#xff01;&#xff01;&#xff01;&#xff01;&#xff01; j j 最后j 才为100 仔细想想也…

sqlserver中获取最后一个字符所在的位置

CHARINDEX(字符,reverse(字段名称)) 这个意思就是将字段进行反转&#xff0c;就是从后往前取&#xff0c;这样就可以获取一个字符最后所在的位置