jquery怎么赋值?
jquery赋值的三种方法:
-
text()
-
html()
-
val()
text() 方法
$("#test1").text("Hello world!");
text() 方法可以设置被选元素的文本内容。
语法:
//设置文本内容: $(selector).text(content) //使用函数设置文本内容: $(selector).text(function(index,currentcontent))
html() 方法
$("#test2").html("<b>Hello world!</b>");
html() 方法可以设置被选元素的内容(innerHTML)。
语法:
//设置内容: $(selector).html(content) //使用函数设置内容: $(selector).html(function(index,currentcontent))
val() 方法
$("#test3").v<strong style="color:transparent">来源gaodai#ma#com搞@代~码网</strong>al("Dolly Duck");
val() 方法设置被选元素的 value 属性。
语法:
//设置 value 属性: $(selector).val(value) //通过函数设置 value 属性: $(selector).val(function(index,currentvalue))
更多jQuery相关技术文章,请访问 jQuery答疑 栏目进行学习!!
以上就是jquery怎么赋值?的详细内容,更多请关注gaodaima搞代码网其它相关文章!