I'm using vw
for previous divs, now I want to set an alert if a div is moved to the very left. Here's the div:
<div id='pagination'>some stuff</div>
Now its width is set to 84vw
, which was calculated from early functions. I want to alert when its margin-left equals -84vw
. I tried this in js but no luck:
if ($('#pagination').css('margin-left') == '-84vw') {
alert('you're good to go!');
}
Could anyone help me with this argument? The real headache is I can't change vw
to px
.
For Conversion of px
and vw
refer this
1px = (100 / document.documentElement.clientWidth)vw
e.g. — If your viewport was 500px
wide (equals by definition to 100vw
) then
1px = (100 / 500) = 0.2vw
Plus you had a syntax error ..Please handle the quotes properly
alert('you\'re good to go!');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With