一、jq改变标签元素的文本值
1、innerText
$('#test').innerText = "我是jq改变元素文本测试";
2、html()
$('#test').html("我是jq改变元素文本测试");
3、text()
$('#test').text("我是jq改变元素文本测试");
二、jq改变元素的属性
1、css()
$('#test').css("display", "none");
$('#test').css({"display": "none","color";"red")};
2、attr()
$('#test').attr("display", "none").attr("color", "red");
$('#test').attr({
display: "none",
color:"red",
name:"test"
});
三、jq设置、获取元素自定义数据
1、data()、dataset()
<h2 data-options = '{"name":"wxz"}' data-name="wxz" id="test"></h2>
$('#test').data("options").name;
$('#test').attr("name");
$('#test').attr("name","hello");