HTML
- html 空格问题
来自百度.jpg
- 强制刷新页面,走服务器请求
onclick="window.location.reload()"
- chrome中取消密码缓存下拉框
autocomplete="new-password"
jQuery
- 一些方法有参为setter,没参为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); 不起作用
- 将事件注册到document级别,使js动态添加的新标签也能触发事件
$(document).on("click",".class-name",function(e){
//do something
});
- 绑定hover事件
// 使能标签的hover效果,新增加标签都需要调用该方法
function resumeHover(){
//当鼠标移动到一个匹配的元素上面时,会触发指定的第一个函数。
//当鼠标移出这个元素时,会触发指定的第二个函数。
$(".class-name").hover(function() {
//do something
},function() {
//do no hovered something
})
}
- hover效果的另一种实现
//监听鼠标的over、out事件
$(document).on("mouseover mouseout",".classname",function(e){
if(e.type == "mouseover"){
//do something
}else{
//do something
}
})
- 监听浏览器大小的改变
$(window).resize(function(){
alert($(this).height());
});
JavaScript
- 数字转字母
String.fromCharCode(i+65); //得到A
Thymeleaf
- 界面首次加载,javascript中使用model的值
<script th:inline="javascript">
/*<![CDATA[*/
var user = /*[[${user}]]*/'';
/*]]>*/
</script>