Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Adding a stylesheet switcher - but how to add an ID to the stylesheet url?
I need to add a stylesheet switcher on my forums. I have a script using jQuery but it requires that the stylesheet I wish to replace have an ID I can hook into.
e.g.
So how can I add an ID parameter to the custom.css stylesheet link?
I don't mind if it's a hack as it's just the one domain.
e.g.
<link id="styletoswitch" rel="stylesheet" type="text/css" href="/minimal/themes/Minimal/design/custom.css?v=1.0" media="screen" />
So how can I add an ID parameter to the custom.css stylesheet link?
I don't mind if it's a hack as it's just the one domain.
0
Answers
so you could use
$('link[href*="/design/custom.css"]')
or add an id dynamically$('link[href*="/design/custom.css"]').attr('id','styletoswitch')
you can also do it in php but why bother?
grep is your friend.
As the href for that changes depending on the style that is set.
$('link:eq(1)')
is this going to be reliable though? I would use something more specific.
If the style changes but there is a general pattern such as a prefix then you could use that.
http://api.jquery.com/category/selectors/
grep is your friend.
$('link[href*="custom"]')
grep is your friend.