我想做这样的事情:
var html = $("#media").html(); $("#multimedia-content").append(html); $("#multimedia-content").filter("*").removeAttr("id");
第3行失败,我想从html的这一部分中删除所有id,但我不知道如何进行选择.
谢谢!
解决方法
就个人而言,我会试试这个:
$('#media') // grab the media content .clone() // make a duplicate of it //.find('*') // find all elements within the clone .removeAttr('id') // remove their ID attributes //.end() // end the .find() .appendTo('#multimedia-content'); // Now add it to the media container
如果您希望#media也丢失其ID,请删除.find()和.end()行,否则取消注释.