سؤال

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

هل كانت مفيدة؟

المحلول

.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();

نصائح أخرى

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();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top