新增元素

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  </head>
<body>

	<button type="button" id="buttonid">点击新增元素</button>
	
	<script>
		$('#buttonid').bind('click', function() {
			//append() - 在被选元素的结尾插入内容
			//prepend() - 在被选元素的开头插入内容
			//after() - 在被选元素之后插入内容
			//before() - 在被选元素之前插入内容
			
			//$("#buttonid").append("<h5>这是新增的标题</h5>");
			//$(this).append("<h5>这是新增的标题</h5>");
			
			$(this).after("<h5>这是新增的标题</h5>");
		});
	</script>
	
</body>
</html>

  

原文地址:https://www.cnblogs.com/helloweworld/p/4797552.html