JQuery not working in IE

I have code that works fine in FF, but not in IE. I read other posts that the jQuery Live method does not support change events, but I am using the click event. Here is my code, it is inside $ (document) .ready (function ():

$("a").live("click", function(e) { 
        alert("link clicked");
        //do stuff
    });

If FF, a warning is raised, but not in IE. When I use $ ("a"). Clicking on it works fine, the problem is that I need a function that will be applied to links that do not exist on the first page load (they will be created via ajax calls later on).

Do I have any options. We are using jquery-1.4.1.min.js.

Thanks in advance

+3
source share
2 answers

, :

$('#link_container_id').delegate('a', 'click', function(e){
   alert('link clicked');
});

.delegate() , - ( ), "" . , .

+2

DOM live. (, ajax), . , , , , , live, click.

+1

Source: https://habr.com/ru/post/1740423/


All Articles