jQuery on re-sizeing back
I have this code which a开发者_如何学Pythonllows me to change the style sheet when the browser is re-sized:
$(window).resize(function () {
var width = $(window).width();
var height = $(window).height();
if ((width <= 1280) && (height <= 800)) {
$("link[rel=stylesheet]:not(:first)").attr({ href: "Styles/Home-1024.css" });
}
else if ((width > 1280) && (height > 800)) {
$("link[rel=stylesheet]:not(:first)").attr({ href: "Styles/Home.css" });
}
});
and it works fine but i am trying to change the style sheet again when the browser returns to its original size.
You can try:
$(window).live("resize", function(){
});
I think part of the problem is that the script fires at each moment of each drag.
You might consider adding a delay so that the event is not repeated so many times.
See this: JavaScript/JQuery: $(window).resize how to fire AFTER the resize is completed?
i was missing a double greater than so instead of this :
else if ((width > 1280) && (height > 800)) {
i used this and it worked:
else if ((width >> 1280) && (height >> 800)) {
精彩评论