getAttribute:取得属性;
setAttribute:设置属性;

 

代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    
<head>
        
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        
<title>Untitled Document</title>
        
<script language="JavaScript">
            
function change() {
                
var input = document.getElementById("li1");
                alert(input.getAttribute(
"title"));
                input.setAttribute(
"title""mgc");
                alert(input.getAttribute(
"title"));
            }
        
</script>
    
</head>
    
<body>
        
<ul id="u">
            
<li id="li1" title="hello">Magci</li>
            
<li>J2EE</li>
            
<li>Haha!</li>
        
</ul>
        
<input type="button" value="Change" onClick="change();" />
    
</body>
</html>

 

 

相关文章:

  • 2021-09-20
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案