动态创建的DOM元素进行事件绑定

http://files.cnblogs.com/files/xsmhero/jquery.livequery.js

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js'></script>
<script type="text/javascript" src="jquery.livequery.js"></script> <input type="button" id="create" value="点击这里" />
<div id="msg"></div>
<script type="text/javascript">
function checkName(id){
  alert('验证NAME');
}
$(function(){
$("#create").click(function(){
var vv ="<input type=\"text\" id="name" name=\"name\" onblur=\"checkName('name')\" />");
$("#msg").html(v);
});
$("#name").livequery('blur',function(){
alert('绑定了单击事件');
    checkName($(this).attr("id"));
}); }); </script>
<input type="button" id="create" value="点击这里" /> 
上一篇:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is


下一篇:opnet的sink模块学习 分类: opnet 2014-05-18 10:28 161人阅读 评论(0) 收藏