开发者

.width() not working in jQuery

开发者 https://www.devze.com 2023-03-19 11:39 出处:网络
I want to do something like this in JQuery 开发者_如何学Pythonif($(this).width() < 400px){ //do something

I want to do something like this in JQuery

开发者_如何学Pythonif($(this).width() < 400px){
      //do something
}

But it didnt work like that....mhm how is it correct?


width() returns a plain number, and even if not your code would have an undefined symbol since 400px is not in quotes - instead use it like this:

if($(this).width() < 400){
      //do something
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号