我試圖從<img>
元素中刪除已加載的圖像,但清除或刪除src不會執行此操作。該怎麼辦?使用jQuery清除IMG
HTML:
<img src='https://www.google.com/images/srpr/logo3w.png'>
JQUERY:
$('img').attr('src', ''); // Clear the src
$('img').removeAttr('src'); // Remove the src
圖片依然存在,
小提琴:http://jsfiddle.net/6x9NZ/
你是什麼意思通過清除IMG?你想從DOM中刪除img元素? – dievardump
不清除從img元素加載的圖像 – Yarin
那麼,它不會留在每個兄弟。你能否給出一個例子,說明你需要什麼行爲來清除src屬性而不從DOM中移除img元素? – dievardump