我試圖刪除使用JS/jQuery的CSS樣式表。當我只知道部分網址時,如何刪除樣式表?
我知道它將在'head'元素中,幷包含文本:civicrm.css,但我不知道其餘的url。
是不是有點像?:
if $("head:contains('civicrm.css')") {
remove the entire link it is part of.
}
目前,我只是在做這樣的:
('link[rel=stylesheet][href~="/thelinkaddress/civicrm.css?r=vrigl"]').remove()
但最後幾個字母經常改變。
['〜='](https://api.jquery.com/attribute-contains-word-selector/)用於查找包含單詞的屬性,其中as ['* ='](https:// api.jquery.com/attribute-contains-selector/)用於查找包含值的屬性(注意「word」的上下文) –
yes your right =),感謝這兩個屬性的純粹分離:) –
偏離主題,但最好引用MDN而不是W3Schools http://www.w3fools.com/ –