<(|要玩通宝娱乐7298游戏中心,可以吗|)&gt

&!DOCTYPE HTML&&html&&head&&meta http-equiv=&Content-Type& content=&text/ charset=utf-8& /&&title&认识table表标签&/title&&span style=&color:#FF0000;&&&strong&&style type=&text/css&&table tr td,th{border:1px solid #090;//为表格添加边框:像素是1px 实体solid 颜色#000}&/style&&/strong&&/span&&/head&&body&&strong&&span style=&color:#FF0000;&&//摘要&/span&&em&summary&/em&&span style=&color:#FF0000;&&的内容是不会在浏览器中显示出来的。它的作用是增加表格的可读性(语义化),//使搜索引擎更好的读懂表格内容,还可以使屏幕阅读器更好的帮助特殊用户读取表格内容。&/span&&/strong& &table summary=&本表格记录2013年到2014年库存记录,记录包括U盘和耳机库存量&&&caption&年库存记录&/caption&strong&&span style=&color:#CC0000;&&&//用以描述表格内容,标题的显示位置:表格上方。&/span&&/strong&&tr&&th&产品名称 &/th&&th&品牌 &/th&&th&库存量(个) &/th&&th&入库时间 &/th&&/tr&&tr&&td&耳机 &/td&&td&联想 &/td&&td&500&/td&&td&&/td&&/tr&&tr&&td&U盘 &/td&&td&金士顿 &/td&&td&120&/td&&td&&/td&&/tr&&tr&&td&U盘 &/td&&td&爱国者 &/td&&td&133&/td&&td&&/td&&/tr&&/table&&/body&&/html&&ul id=getcolor&
&li&&a href="http://s.yanghao.org/program/#" &11&/a&&/li&&li&&a href="http://s.yanghao.org/program/#" &22&/a&&/li&&li&&a href="http://s.yanghao.org/program/#" &33&/a&&/li&&li&&a href="http://s.yanghao.org/program/#" &44&/a&&/li&
&/ul&我想用jquery获取当前点击的&a&标签的值,并且同时添加一个属性class。并且把别的&a&标签的属性移除我的是这样的,已经获取到了&a&标签值,但是怎么添加属性都不对var lis = $("#getcolor li");
(i=0;i&lis.i++){
lis[i].onclick=function(){
alert(this.getElementsByTagName("a")[0].innerHTML);
//在这里添加属性和移除别的a标签属性,该怎么写??? }
}另外this.getElementsByTagName("a")[0].innerHTML这句,在jquery中有没有方法代替?
--------------------------------------
&script type="text/script"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&
--------------------------------------
$("#getcolor li").click(function(){
$(this).children("a").addClass("class1").parent().siblings().find("a").removeClass("class1");});
--------------------------------------
引用 1 楼 xzy21com 的回复:&script type="text/"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&另外this.getElementsByTagName("a")[0].innerHTML这句,在jquery中可替换为$(this).find("a").eq(0).text()
--------------------------------------
因为a是行内替换,对其宽度什么不太容易统一控制,还是操作li的样式比较好。$(function() {$("ul li").d("click",function() {
$(this).addClass("selected").siblings().removeClass("selected");});});
--------------------------------------
引用 3 楼 u 的回复:Quote: 引用 1 楼 xzy21com 的回复:&script type="text/javascript"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&另外this.getElementsByTagName("a")[0].innerHTML这句,在jquery中可替换为$(this).find("a").eq(0).text()这样写的话,是直接获取到了a标签吧。那又怎么获取到值呢
$("#getcolor li a").click(function(){
alert($(this).find("a").eq(0).text());
alert($(this).eq(0).text());
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})这两种alert都不行
--------------------------------------
引用 1 楼 xzy21com 的回复:&script type="text/javascript"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&这个又怎么获取到值呢?我用3楼的替换方法这么写,得不到值。这个是直接获取到了a标签吧,那就不用再find了。但是还不行
$("#getcolor li a").click(function(){
alert($(this).find("a").eq(0).text());
alert($(this).eq(0).text());
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
--------------------------------------
引用 3 楼 u 的回复:Quote: 引用 1 楼 xzy21com 的回复:&script type="text/javascript"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&另外this.getElementsByTagName("a")[0].innerHTML这句,在jquery中可替换为$(this).find("a").eq(0).text()引用 1 楼 xzy21com 的回复:&script type="text/javascript"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&不好意思,是我搞错了,谢谢二位。已经好了
--------------------------------------
引用 6 楼 Myprettygirl 的回复:Quote: 引用 1 楼 xzy21com 的回复:&script type="text/javascript"&
//点击当前的a添加on类,并给其他a清除类名
$("#getcolor li a").click(function(){
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})&/script&这个又怎么获取到值呢?我用3楼的替换方法这么写,得不到值。这个是直接获取到了a标签吧,那就不用再find了。但是还不行
$("#getcolor li a").click(function(){
alert($(this).find("a").eq(0).text());
alert($(this).eq(0).text());
$(this).addClass("on").parent().siblings().find("a").removeAttr("class");
})直接$(this).text()就是a里的值了}

我要回帖

更多关于 通宝娱乐05520老品牌 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信