注释里,法一,jq点击事件里调用函数,直接return为什么不可以
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<style>
.left,
.right {
width: 250px;
height: 130px;
}
.left div,
.right div {
width: 100px;
padding: 5px;
margin: 5px;
float: left;
border: 1px solid #ccc;
background: #bbffaa;
}
.right div {
background: yellow;
}
p {
border: 1px solid red;
}
a {
border: 1px solid blue;
}
</style>
</head>
<body>
<h2>DOM包裹wrapInner()方法</h2>
<div class="left">
<div class="aaron2">点击,通过wrapInner的回调方法给每个div元素增加内部父容器a</div>
</div>
<div class="left">
<div class="left1">a元素</div>
<div class="left1">a元素</div>
</div>
<script type="text/javascript">
$(".aaron2").on("click",function(){
return "$('.left1').wrapInner('<p></p>')";//法一
/*$(".left1").wrapInner(function(){
return "<p></p>";
});*///法二
/* $(".left1").wrapInner("<p></p>");*///法三
});
</script>
</body>
</html>