发这篇博客就是想每天记录一些自己感觉有价值的东西,希望自己可以每天坚持学习,越来越强大,实现自己的梦想。持续更新。
1。 Jquery 获得 下拉列表 选中的值和文本
var selected=$("#selectd option:selected");
var id= v_selected.get(0).value;
var value=v_selected.text();
2。
document.forms[" formName "]. itemName .value= "";
//表单集-->name或Id是formName的表单-->获得表单内元素的值.
window.frames[" iframeName "].document. formName . itemName .value="";
//框架集-->name或Id是iframeName的框架-->获得name是formName的表单-->获得表单元素.
用"."去获得页面元素时,一般都是以name去查找。
3。javascript 是否可以多线程?这篇文章讲的很好。http://www.phpv.net/html/1700.html
4、自己用javascript写了一个实现随机数的例子。
<html> <head> <script> var MyInterval; var clickOrnot = true; function startCount(){ if(clickOrnot){ MyInterval = setInterval(function a(){document.getElementById("txt_start").value=(Math.round(Math.random()*10000));},10); clickOrnot = false; } } function endCount(){ clickOrnot = true; clearInterval(MyInterval); document.getElementById("txt_end").value = document.getElementById("txt_start").value; } </script> </head> <body> <form> <table> <tr> <th> <input type="button" value="start" onclick="startCount();"/> </th> <td> <input type="text" id="txt_start" name="txt_start" style="width:150px;"/> </td> </tr> <tr> <th> <input type="button" value="end" onclick="endCount();"/> </th> <td> <input type="text" id="txt_end" name="txt_end" style="width:150px;"/> </td> </tr> </table> </form> </body> </html>