
原型 - 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
廣告