Delete a specific list item in JavaScript
To delete a specific list item in JavaScript, you can use querySelector() method to return the div that contains that list, then loop over all the li elements in that div and check if the a tag contains the text "deBUG" if so delete it.
var listDiv = document.querySelector('.URL-links');
var listItems = listDiv.querySelector('li');
listItems.forEach( item => {
var a = item.querySelector('a');
if ( a.innerText == "deBUG"){
item.remove();
}
});
or you can delete the link by it hypertext reference by changing the if condition to:
if ( a.href == "www.debug.to") {
item.remove();
}
This might also be done with jquery:
$(‘.URL-links’).find(‘li’).each( function () { if($(this).find(‘a[href*=“debug”]’).length > 0 ) $(this).remove(); });