jquery中append()向元素内追加元素

时间:2023-02-11 10:44:27
<!DOCTYPE html>
<html>
<meta charset="UTF-8">


<head>
<title>append()方法追加内容</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
</head>
<body>
<h3>append()方法追加内容</h3>
<input type="button" value="click" onclick="showWord()">
<script type="text/javascript">
function rethtml() {
var $html = "<div id='test' title='hi'>我是调用函数创建的</div>"
return $html;
}
function showWord(){
$("body").append(rethtml());
}
</script>
</body>
</html>
</body>
</html>