Jquery摘要
来源:互联网 发布:网络电视上的直播软件 编辑:程序博客网 时间:2024/06/02 11:33
1 绑定事件传递参数
$("#Android_Jump_Content").bind('click', 'Android', display_jump_content)
不能直接在函数后面添加参数,否则表示函数调用,函数调用的结果绑定在click事件上
$("#Android_Jump_Content").bind('click', display_jump_content('Android'))
2 判断元素是否存在
var table = $("#to_add_jump_table")
if (table == undefined || null == table || table.length == 0){
//元素不存在
}
3 在事件方法中,根据事件对象获取
$("#to_add_jump_table .glyphicon-remove").on('click', function () {
console.log('remove record')
var record = $(this).parent().parent()
record.remove()
//$("#to_add_jump_table").removeChild(record)
})
需要用$(this),把事件对象转化为jquery对象
4 ajax error方法,当响应码为204,则也会进入到error方法。
(如果服务端响应码为200,但是没有响应体,则ajax做视为204处理)
$.ajax({
type: "GET",
url: "/jump/xx",
data: {"type": osType},
dataType: "json",
async: true,
success: function (data) {
console.log('success to deploy')
display_jump_content(event)
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log('fails to deploy')
console.log(XMLHttpRequest.readyState + XMLHttpRequest.status + XMLHttpRequest.responseText)
handle_jump(null)
}
});
说明,和参数 dataType: "json" 有关,如果没有设置 dataType: "json",则没有响应体时,则进入到success方法
- Jquery摘要
- JQuery摘要
- jQuery摘要
- JQuery功能摘要
- jquery,js代码摘要
- jQuery基础教程 · 摘要
- jquery效果(笔记摘要)
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 摘要
- 字符串处理 - ANSI - Unicode - UTF8 转换
- 心灵治疗术(自我剖析)
- 先进的自动布局工具箱
- AcroIEHelper.dll无法写入,Verify that you have access to that directory
- FreeRTOS系列第11篇---FreeRTOS任务控制
- Jquery摘要
- html5 file api 读取本地文件
- Android在Button按钮上同时显示文字和图片
- 怎么在map上进行迭代(java)
- (转)Java中String类的方法及说明
- Tomcat 远程调试(remote debug)
- JPA2.1 中三个提升应用性能的新功能
- Swarm中binpack策略引起的棘手问题
- Layout Inflation as Intended