开发者

Use jQuery to disable externally linked .js/.css in header?

Is it possible to use jQuery to disable/comment out a header file and then later re-enable it, sort of toggle it on/off disab开发者_如何学Pythonle/enable it?


Try this (for css files):

$('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', '');

  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜