最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - JQuery live doesn't work - Stack Overflow

matteradmin7PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far