原型 - writeAttribute() 方法
此方法会添加、指定或删除以散列或名称/值对传递的属性。
语法
element.writeAttribute(attribute[, value]); OR element.writeAttribute(attributes);
返回值
HTML 元素。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
$('test').writeAttribute("align", "right" );
}
</script>
</head>
<body>
<p id = "test" align = "center" >Formatted Paragraph</p>
<br />
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>
输出
prototype_element_object.htm
广告