Disable button if margin-left = -3200

前端 未结 1 1027
慢半拍i
慢半拍i 2021-01-23 08:03

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 functi

相关标签:
1条回答
  • 2021-01-23 08:27

    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');    
    }
    
    0 讨论(0)
提交回复
热议问题