【发布时间】:2016-03-11 21:27:36
【问题描述】:
为什么下面的代码不起作用,但是在我使用before() 和after() 替换 prepend 和 append 后它会起作用。
<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("img").prepend("<b>Before</b>");
});
$("#btn2").click(function(){
$("img").append("<i>After</i>");
});
});
</script>
</head>
<body>
<img src="/images/logo.png" >
<br><br>
<button id="btn1">Insert before</button>
<button id="btn2">Insert after</button>
</body>
</html>
Thanks,
Ethan
【问题讨论】:
标签: javascript jquery html