문제

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