是否可以使用 jQuery 禁用/注释掉头文件,然后重新启用它,打开/关闭禁用/启用它?
问问题
429 次
1 回答
0
试试这个(对于 css 文件):
$('link[type="text/css"]').each(function(){
var $ele = $(this);
//check if atribute data is set and has info
if ($ele.attr('data') !== undefined && $ele.attr('data') !== ''){ //set, so adding that info to href attribute and emptying data attribute
$ele.attr('href', $ele.attr('data'));
$ele.attr('data', '');
} else{ //not set/empty, so setting/filling it and emptying href attribute
$ele.attr('data', $ele.attr('href'));
$ele.attr('href', '');
}
});
于 2011-06-27T07:13:03.557 回答