[英]JQuery live doesn't work
当有一个密钥时,我试着将.live内容放入div ...我在这里查看了forumtopic但是我没有找到答案......
为什么我的代码不起作用? 我用这个JQuery:
<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// When the document is ready set up our sortable with it's inherant function(s)
$(".atleetnaamlink").live('keyup', function(){
alert('test');
});
</script>
尝试on
$(selector).live(events, data, handler); // jQuery 1.3+
$(document).delegate(selector, events, data, handler); // jQuery 1.4.3+
$(document).on(events, selector, data, handler); // jQuery 1.7+
$(document).ready(function() {
$("body").on('keyup' ,'.atleetnaamlink', function(){
alert('test');
});
});
.live()
已弃用。 请改用.on()
。 那可行。
$(".atleetnaamlink").on('keyup', function(){
alert('test');
});
你错过了});
和工作演示 http://jsfiddle.net/JwRRH/
希望它有所帮助:)
顺便说一下live
是不赞成的,如果你热衷于检查这个jQuery live方法有什么问题?
码
$(document).ready(function() {
// When the document is ready set up our sortable with it's inherant function(s)
$(".atleetnaamlink").live('keyup', function(){
alert('test');
});
});
要么*
$(document).ready(function() {
// When the document is ready set up our sortable with it's inherant function(s)
$(document).live('keyup',".atleetnaamlink", function(){
alert('test');
});
});
添加以上内容:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js"></script>
看看这是否有效
重要的是不要忘记接受它,如果它解决了你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.