Why the code below doesn't work, but It will work after I use before()
and after()
to replace prepend and 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