HTML
- html 空格問(wèn)題
來(lái)自百度.jpg
- 強(qiáng)制刷新頁(yè)面,走服務(wù)器請(qǐng)求
onclick="window.location.reload()"
- chrome中取消密碼緩存下拉框
autocomplete="new-password"
jQuery
- 一些方法有參為setter,沒(méi)參為geteer,例如:
JqueryObject.val("setter");//setter方法
var value = JqueryObject.val();//getter方法
- jQuery選擇器需要 [i] 后才能 .checked = true
//html部分
<input class="hh" type="radio" name="nn">hello</input>
<input type="radio" name="nn">world</input>
//js部分
$(".hh")[0].checked = true;
//$(".hh").checked = true; 不起作用
alert($(".hh")[0].checked);
//alert($(".hh")[0].checked); 不起作用
- 將事件注冊(cè)到document級(jí)別,使js動(dòng)態(tài)添加的新標(biāo)簽也能觸發(fā)事件
$(document).on("click",".class-name",function(e){
//do something
});
- 綁定hover事件
// 使能標(biāo)簽的hover效果,新增加標(biāo)簽都需要調(diào)用該方法
function resumeHover(){
//當(dāng)鼠標(biāo)移動(dòng)到一個(gè)匹配的元素上面時(shí),會(huì)觸發(fā)指定的第一個(gè)函數(shù)。
//當(dāng)鼠標(biāo)移出這個(gè)元素時(shí),會(huì)觸發(fā)指定的第二個(gè)函數(shù)。
$(".class-name").hover(function() {
//do something
},function() {
//do no hovered something
})
}
- hover效果的另一種實(shí)現(xiàn)
//監(jiān)聽(tīng)鼠標(biāo)的over、out事件
$(document).on("mouseover mouseout",".classname",function(e){
if(e.type == "mouseover"){
//do something
}else{
//do something
}
})
- 監(jiān)聽(tīng)瀏覽器大小的改變
$(window).resize(function(){
alert($(this).height());
});
JavaScript
- 數(shù)字轉(zhuǎn)字母
String.fromCharCode(i+65); //得到A
Thymeleaf
- 界面首次加載,javascript中使用model的值
<script th:inline="javascript">
/*<![CDATA[*/
var user = /*[[${user}]]*/'';
/*]]>*/
</script>