Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有一些类似的标题(例如,here、here和here),但我拒绝相信它看起来像它们所暗示的那样复杂。下面给出了值“20px”。我怎样才能让它只返回'20'?
var base=$('#id').css('right');
parseInt()返回解析的整数。
parseInt()
var cssValue = $('#id').css('right'); //returns 20px var parsedCssValue = parseInt(cssValue); //returns 20