1

如何检索元素的clientWidthand scrollWidth?使用getCssValue不起作用

$('.grid-header-col .title').getCssValue('scrollWidth')
4

2 回答 2

1

您应该getAttribute()改用:

element(by.css('.grid-header-col .title')).getAttribute('scrollWidth');
于 2014-12-11T03:52:55.707 回答
0

Both scrollWidth and clientWidth are properties of DOM element. So you need to get the dom element first by attaching [0] after a jquery object and then retreive the properties.

$('.grid-header-col .title')[0].scrollWidth
$('.grid-header-col .title')[0].clientWidth

DEMO

于 2014-12-11T04:21:47.953 回答