How to Switch StyleSheets With jQuery


    [javascript]//Look for the media-type you wish to switch then set the href to your new style sheet
    $(‘link[media=’screen’]’).attr(‘href’, ‘Alternative.css’);
    [/javascript]

    2 Replies to How to Switch StyleSheets With jQuery

    1. Above won’t work.

      You are using single quote far too many times. It should be something like this
      $(“link[media=’screen’]”).attr(‘href’, ‘Alternative.css’);
      Cheers.

    2. Todd Motto says:

      You don’t need to worry about mixing single/double quotes to ‘make it work’ you can unescape the characters like so:

      $(‘link[media=\’screen\’]’).attr(‘href’, ‘Alternative.css’);

    Leave a Reply