В Crome не работает style.borderRight
Почему не работает в Хроме и как бы это исправить?
<div id="itog1" style="width: 120px; height: 120px; margin: 0 auto; border: medium solid rgb(34, 34, 34);"></div> <pre> top: <span></span> right: <span></span> bottom: <span></span> left: <span></span> </pre> <script> var itog = document.querySelector('#itog1'); window.onload = function () { document.querySelector('pre span:nth-of-type(1)').innerHTML = itog.style.borderTop; document.querySelector('pre span:nth-of-type(2)').innerHTML = itog.style.borderRight; document.querySelector('pre span:nth-of-type(3)').innerHTML = itog.style.borderBottom; document.querySelector('pre span:nth-of-type(4)').innerHTML = itog.style.borderLeft; } </script> |
NMitra,
getComputedStyle |
NMitra,
либо искать то что установили Цитата:
|
С getComputedStyle ещё хуже получилось ((
Да, верно, вы правы, спасибо: <div id="itog1" style="width: 120px; height: 120px; margin: 0 auto; border: medium solid rgb(34, 34, 34);"></div> <pre> top <span></span> right <span></span> bottom <span></span> left <span></span> </pre> <script> var itog = document.querySelector('#itog1'); window.onload = function () { document.querySelector('pre span:nth-of-type(1)').innerHTML = itog.style.borderTop; document.querySelector('pre span:nth-of-type(2)').innerHTML = itog.style.borderRightWidth + ' ' + itog.style.borderRightStyle + ' ' + itog.style.borderRightColor; document.querySelector('pre span:nth-of-type(3)').innerHTML = itog.style.borderBottomWidth + ' ' + itog.style.borderBottomStyle + ' ' + itog.style.borderBottomColor; document.querySelector('pre span:nth-of-type(4)').innerHTML = itog.style.borderLeftWidth + ' ' + itog.style.borderLeftStyle + ' ' + itog.style.borderLeftColor; } </script> |
Цитата:
что любопытно - здесь на форуме не работает, если оформить код со словом "run" |
Цитата:
Цитата:
![]() Вот почищенный код: <div id="itog1" style="width: 120px; height: 120px; margin: 0 auto; border: medium solid rgb(34, 34, 34);"></div> <pre> top <span></span> right <span></span> bottom <span></span> left <span></span> </pre> <script> (function () { var itog = document.querySelector('#itog1'); var compStyle = getComputedStyle(itog, ""); document.querySelector('pre span:nth-of-type(1)').innerHTML = compStyle.borderTop; document.querySelector('pre span:nth-of-type(2)').innerHTML = compStyle.borderRight; document.querySelector('pre span:nth-of-type(3)').innerHTML = compStyle.borderBottom; document.querySelector('pre span:nth-of-type(4)').innerHTML = compStyle.borderLeft; })(); </script> |
Часовой пояс GMT +3, время: 02:05. |