Welcome Guest, Not a member yet? Register   Sign In
jQuery e.preventDefault(); stops working after reloading div
#7

[eluser]GrahamDj28[/eluser]
Create a holding container which is not reloaded and remains in the DOM.

Say like:
Code:
<div id="my-list">
    <div class="delete_comment">Blablabla</div>
    <div class="delete_comment">Blablabla</div>
    <div class="delete_comment">Blablabla</div>
    <div class="delete_comment">Blablabla</div>
    <div class="delete_comment">Blablabla</div>
    <div class="delete_comment">Blablabla</div>
</div>

&lt; script &gt;
    $('#my-list').find('.delete_comment').on('click', function(e) {
        e.preventDefault();
    });
&lt;/ script &gt;

But while writing this I think to myself, why reload the DOM?
You can also create new DOM elements and append them to the list which is already there.

And if al you want is to prevent a link from executing you can add the attribute onClick="return false" to the <a> tag.


Messages In This Thread
jQuery e.preventDefault(); stops working after reloading div - by El Forum - 05-03-2012, 02:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB