Skip to content Skip to sidebar Skip to footer

JQuery Remove Function Not Doing Anything

I have a function in my jquery that will append a new select class on the click of a link. What I now what to do is remove this class on the click of a button in case a user decid

Solution 1:

Try .on()

$(".navoptions").on('click','.remove',function() {
     $(".hello").remove();
});

Solution 2:

Try this

$('.navoptions').on('click', '.remove', function () {
    $(this).prev().remove().end().remove();
});

DEMO


Solution 3:

Since the SELECT object has been added dynamically, after the initial DOM creation, it is not associated with any listeners.[onClick in your case].

Like the others suggested, use ".on" to add a listener dynamically. You can find the related docs here. http://api.jquery.com/on/


Solution 4:

$(".navoptions").on('click','.remove',function() {
        $(".hello").remove();
});

reference On


Post a Comment for "JQuery Remove Function Not Doing Anything"