Prototype实战教程 6.$

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"">
<html>
  <head>
    <title>$</title>
    <script type="text/javascript" language="javascript"
     src="prototype.js" ></script>
    <script type="text/javascript" language="javascript">
    function test1() {
      var div = $("div1"); // 单个参数
      alert(div.innerHTML);
    }

    function test2() {
      var divs = $("div1", "div2"); // 多个参数
      for (var i = 0; i < divs.length; i++) {
        alert(divs[i].innerHTML);
      }
    }
    </script>
  </head>
  <body>
  <div id="div1">
    div1
  </div>
  <div id="div2">
    div2
  </div>
  <input type="button" value="click1" onclick="test1()" />
  <input type="button" value="click2" onclick="test2()" />
  </body>
</html>

时间: 2025-01-03 07:59:15

Prototype实战教程 6.$的相关文章

Prototype实战教程 8.顶层对象

<html> <head> <title>顶层元素</title> <script src="prototype.js"></script> <script> var Person=Class.create(); Person.prototype={ initialize:function(){}, name:'', birthday:'', age:'', Show:function(){alert(

Prototype实战教程 7.AJAX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Ajax</title> <script type="text/javascript" langu

Prototype实战教程 5.$R

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>$R</title> <script type="text/javascript" languag

Prototype实战教程 4.$H

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>$H</title> <script type="text/javascript" languag

Prototype实战教程 3.$F

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html> <head> <title>$F</title> <script type="text/javascript" language="javascript" src="prototype.js" &

Prototype实战教程 1.$$

<html> <head> <title>Test $$</title> <script src="prototype.js"></script> <script> function test$$(){ /**//* in case CSS is not your forte, the expression below says 'find all the INPUT elements that are

Prototype实战教程 16.string

<html> <head> <title>String Test</title> <script src="prototype.js"></script> <script> function testStrip() { var str=new String(' wanfangdata '); alert(str.strip()); } function teststripTags() { var str

Prototype实战教程 15.ObjectRange

<script src="prototype.js"></script> <div id="div1" style="font-size:20px;font-weight:bold"> ObjectRange </div> <script> var range = $R(1, 10, false); var range2 = $R(1, 10, true); alert(range.me

Prototype实战教程 14.Hash

<script src="prototype.js"></script> <script> // 创建一个对象 var obj = { key1: 1, key2: 2, key3: 3 }; // 将其转换为Hash对象 var hash = $H(obj); // 输出 #<Hash: {'key1': 1, 'key2' : 2, 'key3': 3}> // 输出key1=1&key2=2&key3=3 alert