document.write(location.href); 返回当前网页的网址
document.write(location.pathname); 返回当前URL的路径名
location.assign("网址") 方法加载新的文档。
history.back() history.forward() 转到上\下一页 button=“。。。。”
var r=confirm("Press a button!"); 跳出来的提示框有选项 confirm("文本")
var name=prompt("请输入您的名字",value="Bill Gates") 输入框 prompt("文本","默认值")
var t=setTimeout("javascript语句",毫秒)
setTimeout()
未来的某时执行代码
clearTimeout()
取消setTimeout()
clearTimeout(t); 归零
function stopCount()
{
c=0;
setTimeout("document.getElementById('txt').value=0",0);
clearTimeout(t);
}
先归到0在停止
function stopCount() // 如果是上面的变量的话会停止,如果是t的话回归零
{
c=0;
setTimeout("document.getElementById('txt').value=0",0);
clearTimeout(t);
}
在本教程中,我们将了解到一些广受欢迎的 JavaScript 框架:
jQuery
Prototype
MooTools
引入jQuery getElementById("1") 可以写成 $("#=2")前提是后面的id为<h id="2">
<script>
function myFunction()
{
$("#h01").attr("style","color:red").html("Hello jQuery")
}
$(document).ready(myFunction);
</script>