jQuery html() 方法
jQuery 教程
· 2019-03-27 13:57:56
实例
改变所有 <p> 元素的内容:
$("button").click(function(){
$("p").html("Hello <b>world</b>!");
});
定义和用法
html() 方法设置或返回被选元素的内容(innerHTML)。
当该方法用于返回内容时,则返回第一个匹配元素的内容。
当该方法用于设置内容时,则重写所有匹配元素的内容。
提示:如只需设置或返回被选元素的文本内容,请使用 text() 方法。
语法
返回内容:
$(selector).html()
设置内容:
$(selector).html(content)
使用函数设置内容:
$(selector).html(function(index,currentcontent))
| 参数 | 描述 |
|---|---|
| content | 必需。规定被选元素的新内容(可包含 HTML 标签)。 |
| function(index,currentcontent) | 可选。规定返回被选元素的新内容的函数。
|
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html
Game Programming Patterns
Robert Nystrom / Genever Benning / 2014-11-2 / USD 39.95
The biggest challenge facing many game programmers is completing their game. Most game projects fizzle out, overwhelmed by the complexity of their own code. Game Programming Patterns tackles that exac......一起来看看 《Game Programming Patterns》 这本书的介绍吧!