$(document).ready(function () {
if ((screen.width >= 1024) && (screen.height >= 768)) {
alert('Screen size: 1024x768 or larger');
$("link[rel=stylesheet]:not(:first)").attr({
href: "style2.css"
});
} else {
alert('Screen size: less than 1024x768, 800x600 maybe?');
$("link[rel=stylesheet]:not(:first)").attr({
href: "style1.css"
});
}
});
I’m not getting this part: $("link[rel=stylesheet]:not(:first)").attr
It selects all
linktags, that have an attribute namedrel, whose value isstylesheet, and that is not the first one of the tags. For example, if you had:The selector would pick the last two
linktags. Why? Because it excludes the first one, since the value of therelattribute is notstylesheet, buticon; and excludes the second one, because it’s the first of all thelinks that have the attributerel="stylesheet", andnot(:first)filters this one out.