получить значение style
хотелось бы получить размер шрифта в ячейке таблицы:
var fontTD = document.getElementById("ID").style.fontSize;
alert(fontTD);
возвращает мне пустоту, причем изменить я иогу, а вот получить никак:( :( :( подскажите как лучше сделать, а то я уже начал делать так:
var StyleID = document.styleSheets[0].cssRules;
for (var j=0; j<StyleID.length; j++) {
var reg = "шаблон";
var flags = "i";
var p = regular(reg, flags, StyleID[j].cssText);
if (p) alert(StyleID[j].cssText);
}
function regular(reg, flags, nValue) {
var myReg = new RegExp (reg, flags);
if (myReg.exec(nValue)) return true;
else return false;
}
|
function style( elem ) {
if ( elem.ownerDocument && elem.ownerDocument.defaultView ) {
return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
} else if ( elem.currentStyle ) {
return elem.currentStyle;
}
return null;
}
var fontTD = style( document.getElementById("ID") ).fontSize;
alert( fontTD );
|
devote,
Спасибо, еще и в пикселях получил, то что было нужно! я так понял можно любое значение вытащить? п.с. не могу плюсануть(( |
| Часовой пояс GMT +3, время: 08:28. |