简体   繁体   中英

Get original height of element after it has been altered

How can I get the height at which an element was rendered, after I have changed it's height?

Eg the text make a very long (high) div , then I shorten it to make it look neat and I use overflow:hidden to temporarily cut off excess text. Now, dynamically, I want to resize the div to be as high as it would have been if I never touched it.

How is this possible to do?

CSS & JQuery is welcome.

Thanks

Grab that value prior to the re-size.

You can then save it, and use it, in two different ways:

// grab it as a JS value and keep it stored somewhere
var originalHeight = element.height();

// grab and store the original value in the rel HTML attribute
el.attr("rel", el.height()

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