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)"
})
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)'
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.