javascript学习记录,随时添加
prototype.js的domready事件,和post方式的ajax
1 document.observe("dom:loaded",function(){2 new Ajax.Request('Ajax.asp',{3 method:'post',4 parameters:"action=allusercount",5 onSuccess:function(data){6 alert(data.responseText);7 }8 });9 });
正则替换,要求把文本域里的内容属性加上引号
1 <html> 2 <head> 3 <title>test</title> 4 <script language="javascript"> 5 window.onload=function(){ 6 document.getElementById("getval").onclick=function(){ 7 var str=document.getElementById("test").value; 8 var reg = /([a-zA-Z]+=)([0-9a-zA-Z\u4E00-\uFA29_]+)(\s*)/gi; 9 str = str.replace(reg, '$1"$2"$3');10 alert(str);11 }12 }13 </script>14 </head>15 <body>16 <p>17 <textarea id="test" >18 <font color=red size=1 face=宋体>测试</font>19 <font color=red size=1 face=楷体_GB2312>测试</font>20 </textarea>21 </p>22 <p>23 <label>24 <input type="button" name="getval" id="getval" value="获取">25 </label>26 </p>27 </body>28 </html>
TAG: