In jQuery, the css property of an element, can be returned using methods. One example is the width()
method that returns the width of an element, like this:
$('div').click(function() {
alert($(this).width());
});
However, in vanilla JS, I tried the following code, but it returned null:
document.querySelector('div').onclick = function() {
alert(this.style.width);
}
How can I make it correct? I hope someone could help me with this.