学生做网站的工作室,网站策划案模板,html5网站代理,建设银行U盾不自己弹网站了html(val)方法设置每个匹配元素的html内容。此属性在XML文档上不可用。
html( val ) - 语法
selector.html( val )
这是此方法使用的所有参数的描述- val - 这是要设置的html内容。
html( val ) - 示例
以下是一个简单的示例#xff0c;简单说明了此方法的用法-
简单说明了此方法的用法-
htmlheadtitleThe jQuery Example/titlescript typetext/javascript srchttps://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js/scriptscript typetext/javascript languagejavascript$(document).ready(function() {$(div).click(function () {$(this).html( h1Click another square/h1);});});/scriptstyle.div{ margin:10px;padding:12px; border:2px solid #666; width:60px;}/style/headbodypClick on any square below to see the result:/pdiv classdiv stylebackground-color:blue;/divdiv classdiv stylebackground-color:green;/divdiv classdiv stylebackground-color:red;/div/body
/html
这将产生以下输出- 参考链接
https://www.learnfk.com/jquery/dom-html-val.html