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
<style type="text/css">
    body{color:#333;}
</style>
JS
$("style").append("#content{color:#f00;}");
In Firefox, this adds #content(color:#f00;} beneath the body
declaration.
Which is what I would expect to happen.
In IE I get an error thrown in jquery-1.3b2.js

It may well be that my expectations of append are wrong, if so, it
would be a useful thing for me to know as I am quite new to jQuery.
Many thanks for your time,
Ant




Ricardo Tomasi wrote:
> 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:
>
> $('<style type="text/css"></style>').text(myClass).appendTo('head');
>
> On Jan 14, 12:05�pm, Ant <kalli...@gmail.com> wrote:
> > Hi,
> > I am trying to append css into a pre existing style element.
> > $("style").append(myClass);
> > This works as expected in Firefox, but not IE.
> > The HTML on the page validates to HTML strict, so I'm fairly sure that
> > it's not the issue with IE that append() won't work on incorrectly
> > written elements.
> > If I change my code to $("p").append(myClass); it works as expected.
> >
> > Was just wondering if this is a know issue with IE or jQuery and if
> > anyone had a work around, I am out of ideas that don't involve
> > considerable effort :)
> >
> > Thanks,
> > Ant

Reply via email to