Добраться до определения стиля элемента
Релиб
Форумы       Участники    Календарь    Кто он-лайн?
Добро пожаловать, гость ( Вход | Регистрация )
        



Добраться до определения стиля элемента Expand / Collapse
Автор
Сообщение
08.09.2006 9:20
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

участник
Last Login: 30.11.2006 16:49
Сообщ.: 65, Visits: 694
Уважаемые!

Есть вот такой код:

<html>
<head>
</head>
<script language="JavaScript">

function textareaclick()
{
 var element_ = null;
 var i = 0;

 element_ = window.event.srcElement;
 
 document.getElementById('txt').childNodes.item(0).nodeValue = '\r********* '
                                                             + element_.tagName
                                                             + ' begin *********';

 for (i = 0; i < element_.attributes.length; i++)
  if (element_.attributes.item(i).specified)
   document.getElementById('txt').childNodes.item(0).nodeValue =
    document.getElementById('txt').childNodes.item(0).nodeValue
    + '\r'
    + element_.attributes.item(i).nodeType + ': '
    + element_.attributes.item(i).name + ' = '
    + element_.attributes.item(i).value;
 
 document.getElementById('txt').childNodes.item(0).nodeValue =
  document.getElementById('txt').childNodes.item(0).nodeValue
  + '\r********* '
  + element_.tagName
  + ' end *********';
}

</script>

<body>
 <textarea id="txt" cols=50 rows=20 style="cursor:hand;" onclick="textareaclick();">area</textarea>
</body>
</html>

Так вот в результате получаем style = null,

а надо бы что-то вроде style = cursor:hand

Как быть?

Спасибо.

Сообщ. #904057
09.09.2006 18:41
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

участник
Last Login: 11.09.2006 14:48
Сообщ.: 37, Visits: 376
у атрибута style нет свойства value

function textareaclick()
{
var element_ = null;
var i = 0;

element_ = window.event.srcElement;

document.getElementById('txt').childNodes.item(0).nodeValue = '\r********* '
+ element_.tagName
+ ' begin *********';

for (i = 0; i < element_.attributes.length; i++)
{
if (element_.attributes.item(i).specified)
{
if (element_.attributes.item(i).name == 'style')
{
document.getElementById('txt').childNodes.item(0).nodeValue += '\r'

+ element_.attributes.item(i).nodeType + ': '
+ element_.attributes.item(i).name + ' = '
+element_.style.cssText;

}
else
{
document.getElementById('txt').childNodes.item(0).nodeValue += '\r'

+ element_.attributes.item(i).nodeType + ': '
+ element_.attributes.item(i).name + ' = '
+ element_.attributes.item(i).value;

}
}
}
document.getElementById('txt').childNodes.item(0).nodeValue =
document.getElementById('txt').childNodes.item(0).nodeValue
+ '\r********* '
+ element_.tagName
+ ' end *********';
}
Сообщ. #904111
« пред. тема | след. тема »


Эту тему читают Expand / Collapse
Посетители: 0 (0 гостей, 0 участников, 0 скрыт.участников)
Сейчас нет участников, просматривающих тему.
Модераторы: Alexey, boombastik, bazile, pl

Время GMT +3:00, Сейчас 4:50