如果margin-left = -3200,则禁用按钮 [英] Disable button if margin-left = -3200
本文介绍了如果margin-left = -3200,则禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图弄清楚如果元素上的 margin-left
等于 -3200
像素。以下似乎运行我的功能在网页加载,任何人都可以看到我要去哪里错了? <$ p
$ b
if($('。hero-carousel')offset()。left = -3200){
alert ('测试');
解决方案
pre $ if $('。hero-carousel' ).offset()。left == -3200){
alert('test');
c>点在offset()之前,并且需要使用= =
而不是 =
平等
比较。
pre $ if $('。hero-carousel' ).offset()。left == -3200){
alert('test');
编辑
为了获得保证金,您需要使用css函数而不是offset()。
if($(。hero-carousel)) .css(margin-left)== -3200 +px){
alert('test');
}
I'm trying to figure out how to disable a button if margin-left
on an element is equals to -3200
pixels. Ive the following that seems to run my function on page load, can anybody see where I'm going wrong?
if ($('.hero-carousel')offset().left = -3200) {
alert('test');
}
解决方案
You missed dot
before offset() and need to use ==
instead of =
for equality
comparison.
if($('.hero-carousel').offset().left == -3200) {
alert('test');
}
Edit
For getting margin left you need to use css function instead of offset()
if($(".hero-carousel").css("margin-left") == -3200 + "px") {
alert('test');
}
这篇关于如果margin-left = -3200,则禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文