DHTML實用指南

來源:互聯網
上載者:User

改進CheckBox:
<label for="check1">單擊我可以改變 CheckBox的狀態</lable>
<input type="checkbox" id="check1" value="often" name="checkoften">

使用Label實現快速鍵的功能:
<table width="400" border="0">
  <tr>
    <td><label for="name" accesskey="N">姓名(<u>N</u>)</label></td>
    <td><input type="text" id="name"></td>
  </tr>
</table>

文字框的提示和輸入
<input type="text" name="name" value="請輸入你的姓名" onfocus=this.select() onmouseover=this.focus()>

開啟和關閉一個新的視窗:
<button onClick="NewWindow=window.open('http://blog.csdn.net/zhoujian2003','這是一個新表單','toolbar=no,statusbar=no,width=200,height=200');">開啟我的Blog</button>
<button onClick="NewWindow.close()">關閉我的Blog</button>

數組中的方法:
join()是將數群組轉換成字串,括弧裡的欄位是指定的分隔字元.
<script>
array1=new Array("A","B","C");
document.write(array1.join()+"<br>");
document.write(array1.join(" ")+"<br>");
document.write(array1.join(" and "));
</script>

sort()是排序:

array1=new Array("A","B","C","Z","T","M");
document.write(array1.sort());
------對數字進行排序
array2=new Array("12","56","6","20");
function numSort(num1,num2)
{
 return num1-num2;
}
document.write(array2.sort(numSort));

reverse()是排列順序顛倒:
<script>
array1=new Array("A","B","C","Z","T","M");
document.write(array1.join()+"<br>");
document.write(array1.reverse());
</script>

slice()是截取數組:
<script>
array1=new Array("A","B","C","Z","T","M");
document.write(array1.join()+"<br>");
document.write(array1.slice(1,4).join());
</script>

concat()用來串連數組:
<script>
var array1=new Array("A","B","C","Z","T","M");
var array2=new Array("a","b","c","c");
var array3=array1.concat(array2);
document.write(array1.join()+"<br>");
document.write(array2.join()+"<br>");
document.write(array3.join()+"<br>");
</script>

delete 方法用於刪除數組中的元素:
<script>
var array1=new Array("A","B","C","Z","T","M");
document.write(array1.length+"<br>");
document.write(array1.join()+"<br>");
delete array1[3];
document.write(array1.length+"<br>");
document.write(array1.join()+"<br>");
</script>

這是一個對字串的外觀處理的樣本
<script>
document.write("這是一個對字串的外觀處理的樣本");
var strDemo="歡迎大家訪問我的Blog------http://blog.csdn.net/zhoujian2003";
document.write(strDemo.big()+"<br>");
document.write(strDemo.blink()+"<br>");
document.write(strDemo.bold()+"<br>");
document.write(strDemo.fixed()+"<br>");
document.write(strDemo.fontcolor("red")+"<br>");
document.write(strDemo.fontsize(5)+"<br>");
document.write(strDemo.italics()+"<br>");
document.write(strDemo.small()+"<br>");
document.write(strDemo.strike()+"<br>");
document.write(strDemo.sup()+"<br>");
document.write(strDemo.sub()+"<br>");
</script>

字串的link()方法:
<script>
document.write("我的Blog".link("http://blog.csdn.net/zhoujian2003"));
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.