jQuery IF语句基于浏览器宽度和div的高度 [英] jQuery IF statement based on browser width and a div's height

查看:131
本文介绍了jQuery IF语句基于浏览器宽度和div的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery方面我没用,但是我需要写一个if语句,而且我不确定能得到我想要的确切代码。这就是我想要的伪代码:

I'm useless when it comes to jQuery but I need to write an if statement and i'm unsure of the exact code that would get what I want. This is what i'd like in pseudocode:

如果浏览器宽度小于1670px且div.banner的高度小于1253px,那么让div.title AND div。社交的父母是div.banner否则让div.title和div.social的父母成为身体(或浏览器窗口)

If browser width is less than 1670px AND height of div.banner is less than 1253px then let div.title AND div.social's parent be div.banner else let the parent of div.title and div.social be the body (or browser window)

我希望这是有道理的,我想感谢您给予的任何帮助。

I hope this makes sense and I'd appreciate any help you could give.

推荐答案

if($(window).width() < 1670 && $(".banner").height() < 1253)
{
    var bannerContent = $(".title").html() + $(".social").parent().html();
    $(".banner").html(bannerContent);
}
else
{
    var bodyContent = $(".title").parent().html();
    $("body").html(bodyContent);
}

这篇关于jQuery IF语句基于浏览器宽度和div的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆