/*经过用户技能标签增加样式*/ $(".s-edited").live("hover",function(){ $(this).toggleClass("borderd"); })
===================================
<html>
<head>
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<title>测试</title>
<script type=
"text/javascript"
src=
"../resources/js/jquery-1.11.1.min.js"
></script>
<script type=
"text/javascript"
>
$(
function
(){
$(
".add"
).on(
"click"
,
function
(){
console.log(
"进来了"
);
$(
".info"
).append(
'<div class="delete"><h3>单击我来删除我</h3></div>'
);
});
$(
".info"
).on(
"click"
,
".delete"
,
function
(){
console.log(
"进来了Delete!"
);
$(
this
).remove();
});
});
</script>
</head>
<body>
<h2 class=
'add'
>单击我添加动态元素</h2>
<div class=
"info"
></div>
</body>
</html>
以上代码就是本文对jquery append 动态添加的元素事件on 不起作用的解决方案,希望对大家学习有所帮助。
|