简体   繁体   中英

remove first number from height variable using javascript

var height = $("#divOne").height();

How to remove first number from height variable?

for example if height of this element is 118 I want to be 18.

Try this :

var height = $("#divOne").height().toString();

height = height.substring(1,height.length);

Demo

First convert it into string then use the substring function.

var height = $("#divOne").height();
height = (height.toString()).substring(1);

Just take the remainder from 100.

var height = $("#divOne").height();
height = height%100;
console.log(height);

DEMO

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM