JavaScript DHTML/Node Operation/getAttribute — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:25, 26 мая 2010
Display attributes for hyper link
<source lang="html4strict">
<html> <head>
<title>Show Attribs</title> <script type = "text/javascript"> function showattribs(e) { var e = document.getElementById("website"); var elemList = ""; for (var element in e) { var attrib = e.getAttribute(element); elemList = elemList + element + ": " + attrib + "\n"; } document.write(elemList); } </script>
</head> <body> <a onclick="showattribs()" href="http://www.google.ru" id="website">link</a> </body> </html>
</source>
"getAttribute()" Example
<source lang="html4strict">
<html> <body> <script language="JavaScript"> function function1(){
var m = document.getElementById("myDiv").getAttribute("id"); alert(m);
} </script>
This is a div element
<input type="button" value="Get id attribute value" onclick="function1();"> </body> </html>
</source>