KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have some list item tags in my jsp. Each list item has some elements inside, including a link ("a" tag) called delete. All that I want is to delete the entire list item when I click the link. Here is the structure of my code: $("a").click(function(event) { event.preventDefault(); $(this).parent('.li').remove(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <li id="191" class="li"> <div class="text">Some text</div> <h4><a href="URL">Text</a></h4> <div class="details"> <img src="URL_image.jpg"> <span class="author">Some info</span> <div class="info"> Text <div class="msg-modification" display="inline" align="right"> <a name="delete" id="191" href="#">Delete</a> </div> </div> </div> </li> But this doesn't work. I'm new at jQuery, so I tried some things, like for example: $(this).remove(); This works, it deletes the link when clicked. $("#221").remove(); This works, it deletes the indicated list item, but it's not "dynamic". Can someone give me a tip?
Tags (comma-separated)
Save Edits
Cancel