[jQuery] Re: .append() into style element causes error in IE only

2009-01-27 Thread Spot
Hi, I found this thread when searching on this subject. I have an app here where we let the user customize almost every single piece of the UI. This requires that we dynamically generate the CSS off a tagged template. What I want to be able to do is completely scrap the current style data and

[jQuery] Re: .append() into style element causes error in IE only

2009-01-15 Thread KidsKilla
You can use an alternative way: var el = $('').appendTo('head').attr({ media: media, id:id, type: 'text/css' })[0]; if(el.styleSheet !== undefined && el.styleSheet.cssText !== undefined) {

[jQuery] Re: .append() into style element causes error in IE only

2009-01-15 Thread Ant
That's been a real help, thanks so much Ant On Jan 15, 4:36 pm, Ricardo Tomasi wrote: > appendChild on a element fails on IE and you get an "unknown > error" if you try to modify it's innerHTML. I haven't found any > workaround. > > Use this to add styles: > > //addStyles 0.1 > // Ricardo Tomas

[jQuery] Re: .append() into style element causes error in IE only

2009-01-15 Thread Ricardo Tomasi
appendChild on a element fails on IE and you get an "unknown error" if you try to modify it's innerHTML. I haven't found any workaround. Use this to add styles: //addStyles 0.1 // Ricardo Tomasi < ricardobeat at gmail com > // Licensed under the WTFPL - [jQuery] Re: .append() into style element causes error in IE only
Hi, Yea, I went for adding a new style element for every new style, which works, but isn't as neat as I was hoping for. I was trying to append a string into the style element: HTML body{color:#333;} JS $("style").append("#content{color:#f00;}"); In Firefox, this adds #content(color:#f00;} be

[jQuery] Re: .append() into style element causes error in IE only

What are you trying to append? You can only append textnodes to a style element. Why not use the stylesheet object directly: document.styleSheets[0].insertRule("#wrapper {display:none}", 0) // 'addRule' on IE Or, for a hassle-free alternative, create a new style element for it: $('').text(myCl