suhail suhail - 1 year ago 42
Ajax Question

jQuery click function doesn't work after ajax call?

The jQuery click function works fine here

<div id="LangTable"><a class="deletelanguage">delete</a></div>


but if I set some
by ajax,
doesn't work.

for example

function CreateRow(jdata) {
$('#LangTable').append('<a class="deletelanguage">delete</a>');

url: "/jobseeker/profile/",
success: CreateRow

Now the
for the last
is not working.

jsfiddle example :

Note: the CSS works fine here.

I want to make these newly appended
working with jQuery click.

Answer Source

The problem is that .click only works for elements already on the page. You have to use something like on if you are wiring up future elements

$("#LangTable").on("click",".deletelanguage", function(){