Hey everyone !
I’ve been struggling for hours trying to do this :/ I’m trying to remove an element from the DOM using jquery.
What I need is jquery to find a specific href link (for example href=”https://www.example.com“), and delete it from the DOM as well as its parent.
I’m trying to do that because I have multiple buttons on a page, each have their own link to another page, and I want to remove a whole button containing a specific link. Is that even possible ?
Thank you !
What you are doing is targeting by attribute: https://www.w3schools.com/jquery/sel_attribute_end_value.asp
$("a[href$='http://www.example.com']").remove();
That didn’t do the trick apparently :/
Is it also possible to delete the parent at the same time ? That might be why it’s not working in my case. I know there’s a “closest” command but I’m not sure of the formatting.
Members
Online