colmtuite colmtuite - 2 months ago 13
Javascript Question

Get CSS transform property with jQuery

I'm trying to get the

-webkit-transform: translateY('')
property in a variable.

HTML

<form class="form-con" style="-webkit-transform: translateY(-802px);"></form>


JS

$('.foo').click(function() {
var current_pull = parseInt($('.form-con').css('transform').split(',')[4]);
});


This is returning '0', instead of the correct value.

Answer
$('.foo').click(function() {
    var current_pull = parseInt($('.form-con').css('transform').split(',')[5]);
});