时间:2018-11-24 22:51
js中Document.location.href和.replace的区别
时间:2018-11-24 22:48
js点击事件跳转
onclick="window.location.href='你的HTML的URL'"
onclick="document.location.href='你的.html'"
window.location、document.location、document.URL 对当前网页进行跳转
我们先来看看 document 与 window对象:
[window 对象] 它是一个顶层对象,而不是另一个对象的属性即浏览器的窗口。
[document 对象] 该对象是window和frames对象的一个属性,是显示于窗口或框架内的一个文档。
document 只是属于window 的一个子对像。
时间:2018-11-24 22:32
<input type=\"submit\" value=\"注册\" />怎样点击注册跳转到html页面
方法:
第一种: OnCilck 属性:
<input type="button" value="注册" onclick="document.location.href='Html 页面的URL'" />
第二种,修改 <Form> 的目标,设定为你的 HTML 页面 URL,好像是 post 属性。
时间:2018-11-21 13:23
JavaScript 输出
JavaScript 没有任何打印或者输出的函数。
JavaScript 可以通过不同的方式来输出数据:
使用 window.alert() 弹出警告框。
使用 document.write() 方法将内容写到 HTML 文档中。
使用 innerHTML 写入到 HTML 元素。
使用 console.log() 写入到浏览器的控制台。
时间:2018-11-21 13:07
js中focus()
js中trim() 去字符串两边的空格
js中test()
时间:2018-11-21 13:02
js中test()方法
定义和用法
test() 方法用于检测一个字符串是否匹配某个模式.
语法
RegExpObject.test(string)
参数 描述
string 必需。要检测的字符串。
例子:
var re = /^[1-9]\d{4,10}$/i;
var str = "123456";
alert(re.test(str)); //返回true
str = "1234567";
alert(re.test(str)); //返回true
时间:2018-11-21 10:30
不在HTML加事件,直接在js中加
需要一个window.onload
例如:
window.onload=function ()
{
var oTxt1=document.getElementById('txt1');
var oTxt2=document.getElementById('txt2');
var oBtn=document.getElementById('btn1');
oBtn.onclick=function ()
{
//alert(typeof oTxt1.value);
alert(parseInt(oTxt1.value)+parseInt(oTxt2.value)); /
};
};
</script>
</head>
<body>
<input id="txt1" type="text" />
<input id="txt2" type="text" />
<input id="btn1" type="button" value="求和" />
</body>
时间:2018-11-20 22:44
js中var是声明变量
例如:
var x; var carname; 在以上声明之后,变量并没有值,不过您可以在声明它们时向变量赋值:var x=5; var carname="Volvo"; 注释:在为变量赋文本值时,请为该值加引号
时间:2018-11-20 22:42
js中!是取反
例如:
if(!checkbox.checked)
时间:2018-11-10 21:48
js中
replace(原本的,要替换的) 替换
时间:2018-11-10 19:24
<div id ="box"></div>
console.log(box)
console.dir(box)
时间:2018-11-10 18:29
js中!是取反
例如:
if(!checkbox.checked)
时间:2019-11-08 22:25
对象.属性 属性:没有()
对象.方法 方法:带有(),()里面是传的参数
对象.属性 = 函数
对象.属性 = function() {}
时间:2018-11-08 22:00
var name = document.getElementsByName('')
一般用于form表单里获取,
注意:getElementsByName只能是document的方法,不能是元素的方法,元素没有这个方法
时间:2018-11-08 21:48
var divs = document.getElementsByTagName('div')
返回的divs是元素的集合
时间:2018-11-08 21:35
对象调用方法,
1.了解方法的作用和功能,
2.参数的意义和类型
3.返回值的意义和类型
4.试一试
传的参数是字符串,用双引或单引
例如:
var div = document.getElementById('div1')
document是对象,
getElementById()是document的方法,div1是传的字符串,
div是返回的值