⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attribute.htm

📁 Windows Web脚本开发指南/(美) Dan Heflin, Todd Ney著 的源码
💻 HTM
字号:
<html>
<script Language="JavaScript">
var theElement;
function load(){
  xmlDocObject.async = false;
  xmlDocObject.loadXML("<sample><singleNode>The Value</singleNode></sample>");
  theElement = xmlDocObject.documentElement.firstChild;
  displayAttributes();
}
function displayAttributes(){
  var attributeObj = null;
  var attributesColl;
  var innerString = "";
  attributesColl = theElement.attributes;
  attributeObj = attributesColl.nextNode();
  while (attributeObj != null){        	
    innerString = innerString + attributeObj.name + " = " + attributeObj.value + "<BR>";
    attributeObj = attributesColl.nextNode();
  }  
  AttributeValues.innerHTML = innerString;
}
function setAttr(){
  var attName = NewName.value;
  var attValue = NewValue.value;
  theElement.setAttribute(attName, attValue);
  displayAttributes();
}
function deleteAttr(){
  var attName = NewName.value;
  theElement.removeAttribute(attName);   
  displayAttributes();
}
</script>
<body onLoad="load()">
<p align="center"><b>Manipulate Attributes</b></p>
<xml ID="xmlDocObject"></xml>
Attribute Values:<BR>
<div ID="AttributeValues"></div>
<p>Attribute Name:<input type="text" ID="NewName">
Value:<input type="text" ID="NewValue"></p>
<input type="button" value="Set Attribute" onClick="setAttr()">
<input type="button" value="Remove Attribute" onClick="deleteAttr()">
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -