Reputation: 73
I want to write my javascript value to translate a CSS class, however it is not working as I want. Can anyone tell me why?
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: "translateY(' + contentHeight + 'px)"
})
Upvotes: 1
Views: 3197
Reputation: 337560
The issue is because you have mismatched quotes; "
as the outer delimiters and '
around where you concatenate the variable. Try this:
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: 'translateY(' + contentHeight + 'px)'
})
Upvotes: 3