33.jQuery的常用方法
作者:
若愚同学 | 来源:发表于
2018-06-12 22:23 被阅读0次$(function() {
//获取jQuery中DOM元素的个数
console.log($("#h1"));
console.log($("#h1").length);
console.log($("#h1").size());
//获取操作元素的value属性值
console.log($("#username").val());
//设置id为username的值为林小书
$("#username").val("林小书");//直接给值则是修改value
console.log($("#username").val());
//对比元素中内容和纯文本的区别
console.log($("#h1").html());//会把元素内部的标签一起打出来
console.log($("#h1").text());//只会将纯文本打印出来
//把id为h1元素的内容改成黄色
$("#h1").css("color","red");
});
本文标题:33.jQuery的常用方法
本文链接:https://www.haomeiwen.com/subject/bmfdeftx.html
网友评论