开发工具与关键技术:html,css,jquery,基础知识
撰写时间:2020-10-08
①单选框、多选框的
相连的单选框name值相同:
获取单选框:var sex=
(
"
i
n
p
u
t
[
n
a
m
e
=
′
s
e
x
′
]
"
)
.
v
a
l
(
)
;
−
−
输
出
v
a
l
u
e
值
获
取
多
选
框
:
v
a
r
s
e
x
1
=
("input[name='sex']").val();--输出value值 获取多选框: var sex1=
("input[name=′sex′]").val();−−输出value值获取多选框:varsex1=("#sex3").is(":checked");–输出true or false
②请求、页面重定向:
1、将地址替换成新 url,该方法通过指定 URL 替换当前缓存在历史里(客户端)的项目,因此当使用 replace 方法之后,你不能通过"前进"和"后退"来访问已经被替换的URL,这个特点对于做一些过渡页面非常有用!
window.location.replace("
c
t
x
/
u
s
e
r
/
t
o
u
p
d
a
t
e
/
{ctx }/user/toupdate/
ctx/user/toupdate/{id2}");
2、跳转到指定的url,类似
window.location.href="
c
t
x
/
u
s
e
r
/
t
o
u
p
d
a
t
e
/
{ctx }/user/toupdate/
ctx/user/toupdate/{id2}";
3、页面跳转不刷新
③blur与focus的简单应用
无法使用文本框
$(“input[name=‘uttl’]”).focus(function(){
this.blur();
})
页面加载完成设置焦点
$(document).ready(function(){
$("#login").focus();
});
失去焦点
$(“input[name=‘uttl’]”).blur(function(){
alert(“123”);
})
文本框输入值不为空跳到下一个文本框
if (oop.length!=0) {
$("#login").val("").focus();
}else{
alert(123);
}
④onkeydown、onkeyup、onclick、onchange、oninput、onpropertychange,
⑤清空form表单