Olivier Peeters
Olivier Peeters

Reputation: 61

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

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>

Upvotes: 3

Views: 2872

Answers (4)

Pragnesh Chauhan
Pragnesh Chauhan

Reputation: 8476

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

Upvotes: 3

Jai
Jai

Reputation: 74738

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.

Upvotes: 0

Tats_innit
Tats_innit

Reputation: 34107

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

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

Upvotes: 1

techfoobar
techfoobar

Reputation: 66663

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

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

Upvotes: 1

Related Questions