.live() to . on()

jquery 1.8.2:


$(".addGuest").live("click", function(){
			var child = $(this).parent();
			var newG = '<tr class="guestName"><td>testing</td></tr>';
			$(child).append(newG);
		});

just downloaded jquery 1.11.1 how do i use .on() ?

TIA

For elements loaded after the DOM, use this:


$(document).on("click", ".addGuest", function(){
  // do stuff
});

Reference: http://api.jquery.com/live/


$( "a.offsite" ).live( "click", function() {
  alert( "Goodbye!" ); // jQuery 1.3+
});
$( document ).delegate( "a.offsite", "click", function() {
  alert( "Goodbye!" ); // jQuery 1.4.3+
});
$( document ).on( "click", "a.offsite", function() {
  alert( "Goodbye!" );  // jQuery 1.7+
});


 $(document).on("click", ".addt-btn" function() {
    	alert("click");
        $( "#Tname" ).dialog( "open" );
      });

doesn’t seem to be working. no alerts. as i have alert(“load”); after (document).ready

You missed the comma after your class name.

yeah i got it. thanks mawburn.