Disable button if margin-left = -3200

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');
}

Answers:

Answer

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');    
}

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.