Jquery Multiple If Else

I have a small bit of code within my script, that reads: function imageresize() { var contentwidth = $('#content').width(); if ((contentwidth) < '840' && ('#content img[src*=aerial]').length>0) { $('.fluidimage').attr('src','images/aerial_sm.jpg'); } else if ((contentwidth) < '840' && ('#content img[src*=locational]').length>0) { $('.fluidimage').attr('src','images/locational_sm.jpg'); } else { $('.fluidimage').attr('src','images/locational.jpg'); } else { $('.fluidimage').attr('src','images/aerial.jpg'); } } Basically it calls in another image should the div be less than 840. The #content div also has another small piece of scripting that swaps the image within the div - so I need to run this depending on if either image is currently shown.
'840' is a string, not a number.

以上就是Jquery Multiple If Else的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准