Quantcast
Channel: click event of jQuery doesnt work for dynamically generated li - Stack Overflow
Viewing all articles
Browse latest Browse all 5

click event of jQuery doesnt work for dynamically generated li

$
0
0

Can someone please have a look at this code in which every function works perfect but only the click event (which is at last of the code)

 $('ul#showUsernames li').on('click', function () {    selectedUsername = $(this).text();    if (selectedUsername != chatUsername) {        chatTitleName.text("Chat between "+ chatUsername +" and "+ selectedUsername);    } });

Here I used .click and also bind('click',function they too didnt work.

I am using on here because I am generating the li elements dynamically through jQuery.

I am not sure whether this matters here or not that I am using SignalR in my project.

Please help.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles



Latest Images