2014-12-11 143 views
1

如何检索元素的clientWidthscrollWidth?使用getCssValue不起作用访问元素值

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

回答

1

您应该使用getAttribute()代替:

element(by.css('.grid-header-col .title')).getAttribute('scrollWidth'); 
0

两个scrollWidth和clientWidth是DOM元素的属性。所以你需要首先获得dom元素,在jquery对象之后附加[0],然后检索属性。

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

DEMO