[英]JQuery live doesn't work
I try to get .live content into a div when there is a keyup... I looked at the forumtopic here but I didn't find the answer... 当有一个密钥时,我试着将.live内容放入div ...我在这里查看了forumtopic但是我没有找到答案......
Why does my code not works? 为什么我的代码不起作用? I use this JQuery: 我用这个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>
try on
尝试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()
is deprecated. .live()
已弃用。 Use .on()
instead. 请改用.on()
。 That will work. 那可行。
$(".atleetnaamlink").on('keyup', function(){
alert('test');
});
You are missing });
你错过了});
and Working demo http://jsfiddle.net/JwRRH/ 和工作演示 http://jsfiddle.net/JwRRH/
Hope it helps :)
by the way live
is deprecated and if you keen check this out What's wrong with the jQuery live method? 希望它有所帮助:)
顺便说一下live
是不赞成的,如果你热衷于检查这个jQuery live方法有什么问题?
code 码
$(document).ready(function() {
// When the document is ready set up our sortable with it's inherant function(s)
$(".atleetnaamlink").live('keyup', function(){
alert('test');
});
});
or* 要么*
$(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');
});
});
Add this above: 添加以上内容:
<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>
and see if this works. 看看这是否有效
and important thing not to forget to accept it if it solves your issue. 重要的是不要忘记接受它,如果它解决了你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.