Reputation: 2201
I'm trying to remove a stylesheet that is dynamically being added to the end of <head>
tag
For some reasons, i'm forced to use javascript to remove that stylesheet tag and add my own
here is the code i tried -
jQuery(document).ready(function(){
jQuery('link[href^="somepath/editor.css"]').remove();
jQuery('head').append("<link href='somepath/custom/editor.css' type='text/css' rel='stylesheet' />");
});
the problem is that this function is being executed before the CkEditor functions. So my Stylesheet is being added before the ckeditor stylesheet and the ckeditor stylesheet
I tried using .load
instead of .ready
but then the code doesn't seem to run at all.
Any help?
Upvotes: 0
Views: 81
Reputation: 97672
If you don't know when the css will be added you can use setInterval to poll for it.
var interval = setInterval(function(){
var css = jQuery('link[href^="somepath/editor.css"]')
if (css.length){
css.remove();
jQuery('head').append("<link href='somepath/custom/editor.css' type='text/css' rel='stylesheet' />");
clearIntrval(interval);
}
}, 500);
Upvotes: 1