Snippets Collections
let heightStr = '56.54px';

let number = parseFloat(heightStr.replace('px', ''));
console.log(number)

// or on a DOM Element

 const message = document.querySelector('.message-container');
 console.log(getComputedStyle(message).height);
message.style.height =
    Number.parseFloat(getComputedStyle(message).height, 10) + 22.5 + 'px';
star

Tue Jul 02 2024 01:27:00 GMT+0000 (Coordinated Universal Time)

#dom #css #inline #getcomputedstyle

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension