最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery live doesn't work - Stack Overflow

programmeradmin2浏览0评论

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...

Why does my code not works? I use this 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>

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...

Why does my code not works? I use this 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>
Share Improve this question asked Nov 10, 2012 at 9:30 Olivier PeetersOlivier Peeters 612 silver badges7 bronze badges 1
  • $(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+ – Pragnesh Chauhan Commented Nov 10, 2012 at 9:30
Add a ment  | 

4 Answers 4

Reset to default 3

try 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');
 });  
});

DEMO

.live() is deprecated. Use .on() instead. That will work.

$(".atleetnaamlink").on('keyup', function(){
    alert('test');
}); 

You are missing }); and Working demo http://jsfiddle/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?

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./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.

发布评论

评论列表(0)

  1. 暂无评论