Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread Steve Ivy
Glen,

I use a couple methods:

1) Add an empty LINK and the set the href in the script:

$('#mylinkid').attr('href', stylesheetpath);

2) probably better but a little longer:

$('head').append('link id=mylinkid href=stylesheetpath
rel=stylesheet')

I'm sure someone will chime in here and tell me I'm an idiot, at which
point I'll go fix my own code... :-)

--Steve

[EMAIL PROTECTED] | irc: monkinetic|redmonk



  Original Message 
 Subject: [jQuery] Attach a Style Sheet
 From: Glen Lipka [EMAIL PROTECTED]
 Date: Tue, October 10, 2006 11:44 am
 To: jQuery Discussion. discuss@jquery.com
 
 Is there a simple way to attach a style sheet to the page in jQuery?
 
 Thanks,
 
 Glen
  
 -
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread kenton.simpson

this may also help 

http://www.kelvinluck.com/article/switch-stylesheets-with-jquery

-- 
View this message in context: 
http://www.nabble.com/Attach-a-Style-Sheet-tf2418733.html#a6744899
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread Jörn Zaefferer
kenton.simpson schrieb:
 sorry you said stylesheet, but you get the idea. 
 I haven't tested this yet, but it may work.

 jQuery(document.createElement(link))
   .attr({type: text/css,href: my.css,rel:stylesheet})
   .appendTo(head);
   
To make it even more jQuerish:

jQuery(link)
.attr({type: text/css,href: my.css,rel:stylesheet})
.appendTo(head);


 I dont think that works in IE because jQuery will wrap the link in a div
 element. Which is not allowed in the head. FF seems ok with it even thou its
 not correct. try this.
   
It's true that jQuery creates a div first to use it's innerHTML 
property, but that div is not inserted to the document.

-- Jörn

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread kenton.simpson

Thanks for the info. i did not realize that.
-- 
View this message in context: 
http://www.nabble.com/Attach-a-Style-Sheet-tf2418733.html#a6746281
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread Brandon Aaron
On 10/10/06, Glen Lipka [EMAIL PROTECTED] wrote:
 I tried to make it
 jQuery(link)
 but that didn't seem to work (was looking in IE).  The other one with
 jQuery(document.createElement(link) did work.

 What is the difference between jQuery() and $().  Why should you use one
 over the other?

If you are writting a plugin or patch, then jQuery() should be used.
However, in your own scripts you are encouranged to use the
shorcut/alias $. This makes it easy to change the $ alias to something
else if needed.

--
Brandon Aaron

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Attach a Style Sheet

2006-10-10 Thread Jörn Zaefferer
Brandon Aaron schrieb:
 On 10/10/06, Glen Lipka [EMAIL PROTECTED] wrote:
   
 I tried to make it
 jQuery(link)
 but that didn't seem to work (was looking in IE).  The other one with
 jQuery(document.createElement(link) did work.

 What is the difference between jQuery() and $().  Why should you use one
 over the other?
 

 If you are writting a plugin or patch, then jQuery() should be used.
 However, in your own scripts you are encouranged to use the
 shorcut/alias $. This makes it easy to change the $ alias to something
 else if needed.
   
I'd say: Use $ whenever you want to prototype something, fast. But as 
soon as you are starting to write your code as plugins, use jQuery 
instead, as that guarantees you compatibilty with other librarys that 
rely on the $ alias.

-- Jörn

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/