PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
属性
1.属性
1.1 attr(name|properties|key,value|key,fn)
1) 获取属性值 $("img").attr("src");
2) 设置属性值 $("img").attr("title","你好");$("img").attr({src:"img1.png",alt:"img1"})
3) 设置属性值 $("img").attr("alt",function(index,value){return value + index}) //index为当前元素的索引,value为"alt"原先的属性值
1.2 removeattr(name)
删除一个属性 $("img").removeattr("alt");
1.3 prop(name|properties|key,value|key,fn)
$("input[type='checkbox']").prop("checked", true);
$("input[type='checkbox']").prop("checked", function( i, val ) { return !val; });
1.4 removeprop(name)
用来删除由.prop()方法设置的属性集
1.5 attr() 与 prop() 的区别
具有 true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr()
2.css类
2.1 addclass(class|fn)
$("p").addclasss("active focus");
$("ul li").addclass(function(i,class){return class+i})
2.2 removeclass([name|fn])
$("p").removeclass("active");
$("p").removeclass(function(){return $(this).attr("class")})
2.3 toggleclass(class|fn)
$("p").toggleclass("active");
$(".class").toggleclass(function(){
if($(this).parent().is(".myclass"))
{
return "classone";
}
else
{
return "classtwo";
}
})
3.html代码|文本|值
3.1 html([val|fn])
获取内容 $("div").html() 取得第一个匹配元素的html内容
设置内容 $("div").html("
htmlhtmlhtml
");以上就是jQuery属性与CSS操作的内容,更多相关文章请关注PHP中文网(www.php.cn)!
前端入门到VUE实战笔记:立即学习
>在学习笔记中,你将探索 前端 的入门与实战技巧!
已抢7213个
抢已抢94857个
抢已抢14827个
抢已抢52068个
抢已抢194764个
抢已抢87280个
抢