remove 'px' from number

PHOTO EMBED

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

Saved by @davidmchale #dom #css #inline #getcomputedstyle

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';
content_copyCOPY