Question

I want to remove anchors with href contains "#tab" with a specific css class "atitleTabs" from some specific divs whose Id contains "tab". I have tried the following code it didn't work for me.

 $('div[id*="tab"] a[href*="#tab"])').hasClass(".atitleTabs").remove();

please help me, how can i achieve my goal

Was it helpful?

Solution

.hasClass() returns a boolean value, so your method will fail with an error

$('div[id*="tab"] a.atitleTabs[href*="#tab"]').remove();

or

$('div[id*="tab"] a[href*="#tab"])').filter(".atitleTabs").remove();

OTHER TIPS

Try this:

 $('div[id*="tab"] a.atitleTabs[href*="#tab"])').remove();

Since .hasClass() return a boolean value, in order to chain your selector without modifying most of your code, you can use .filter() instead:

$('div[id*="tab"] a[href*="#tab"])').filter(".atitleTabs").remove();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top