0

How to get id of li tags which are added to the page asynchronously after the page load.

I have tried to with function document.ready but it loads before asynchronous li data load.

e.g In my page there is a news data which loads asynchronously & i dont have any control over it. When user clicks on the news link it goes to some location i need to change it to some other location.

I have tried following code. but it is not working.

    $("a[href*='Pages/results.aspx']").each(function(){ 
        var href = $(this).attr('href').replace('/Pages/results.aspx', window.location.pathname);
        $(this).attr("href", href);
    });
Chitta Sukla
  • 63
  • 4
  • 9

2 Answers2

0

If you are loading your li tags via Ajax then I'd recommend throwing your li modification function into the readystatechange handler, or the success handler if you are using JQuery.

If you are loading the li's via a server back end such as ASP.net then throw your I modification function into jQuery's $(window).load function.

See: http://api.jquery.com/load-event/

Malachi
  • 3,205
  • 4
  • 29
  • 46
N. Taylor Mullen
  • 18,061
  • 6
  • 49
  • 72
0

have you tried to create a function the envelopes the creation of the news feed and after that code changes the li?

I think that way it would be in the same thread and would have to execute in the order that you want it to.

Malachi
  • 3,205
  • 4
  • 29
  • 46