jquery中改变指定div内容的方法:html函数,类似innerHTML函数
改变 html内容
语法:$(selector).html(content)
html() 函数改变所匹配的 HTML 元素的内容(innerHTML)。
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").html("www.qipa250.com");
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button type="button">请点击这里</button>
</body>
</html>

jQuery改变HTML内容

本文介绍如何使用jQuery的html()函数来更改网页上指定div元素的内容。通过一个示例展示了当按钮被点击时,如何将新的内容插入到段落中。
963

被折叠的 条评论
为什么被折叠?



