jQuery if statement depending on width in px

旧城冷巷雨未停 提交于 2019-12-05 21:05:19

.width is a function, that returns a number. So your test should look like this:

if ($brewapp.width() === 900)

I suggest the Mozilla Javascript docs if you want to deepen your JS knowledge.

You need to add only two characters:

if ($brewapp.width() == 900)
{
//what i want it to do
}

I guess your code should be:

if ($brewapp.width() == 900)
{
//what i want it to do
}

First width is a function, so use () and it returns an integer, so no need to append 'px'.

This is the jQuery way. Using the jQuery width() gives better results than using el.style.width (or what you intended to use).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!