I’m trying to convert the following jquery to javascript syntax, but being not familiar with either, I’m getting stuck
var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
// Append our div, do our calculation and then remove it
$('body').append(div);
var w1 = $('div', div).innerWidth();
div.css('overflow-y', 'scroll');
var w2 = $('div', div).innerWidth();
$(div).remove();
You can’t directly translate jQuery into native JavaScript because it’s pulling different tricks for all sorts of variables you couldn’t possibly account for (browsers, browser versions, OSes, etc).
You could attempt to do this but it’d be an incredible waste of your time. The top JavaScript pros are working on these frameworks to make JavaScript easier for you. Don’t undo all their hard work by trying to do it on your own…