=================
2017-3-23
=================
以后写js
放到html底部 不加window.onload DOMContentLoaded
创建
$('<div>abc</div>');
插入
$('<div>abc</div>').appendTo('父级');
$('<div>abc</div>').prependTo('父级');
$('<div>abc</div>').insertBefore('父级');
$('<div>abc</div>').insertAfter('父级');
删除
$(obj).remove();
获取物体信息
$(obj).width()/height;
$(obj).innerWidth()/height;
$(obj).outerWidth()/height;
$(obj).offset().left/top;
$(obj).offsetParent();
事件委托
on
事件绑定
jq里面所有事件默认都是绑定的
on
off
阻止事件冒泡/浏览器默认事件
return false;
链式
插件
this是原生的
$.fn.cs=function (){
...
return this;
};
$.fn.extend({});
选择子级
$(obj).find();
循环
each
-----------------------------------
数据交互 ajax
表单几乎没人用了
提交以后自动刷新(整个页面)
form
action 提交地址
默认不写提交到本地(当前页面)
如果写http,走的是http写,不写走本地
method 传输方式
get 地址栏提交 不安全 32k
post 浏览器内部 相对安全 1G
$.ajax({
url:'地址',
data:{
参数:xxx,
参数:xxx
},
type:'POST/GET',
success:function(str){ //成功回调函数
alert(str);
},
error:function (err){ //失败回调函数
alert(err);
}
});
ajax交互
填写地址
返回结果
解析结果
展示数据
2017-3-23
=================
以后写js
放到html底部 不加window.onload DOMContentLoaded
创建
$('<div>abc</div>');
插入
$('<div>abc</div>').appendTo('父级');
$('<div>abc</div>').prependTo('父级');
$('<div>abc</div>').insertBefore('父级');
$('<div>abc</div>').insertAfter('父级');
删除
$(obj).remove();
获取物体信息
$(obj).width()/height;
$(obj).innerWidth()/height;
$(obj).outerWidth()/height;
$(obj).offset().left/top;
$(obj).offsetParent();
事件委托
on
事件绑定
jq里面所有事件默认都是绑定的
on
off
阻止事件冒泡/浏览器默认事件
return false;
链式
插件
this是原生的
$.fn.cs=function (){
...
return this;
};
$.fn.extend({});
选择子级
$(obj).find();
循环
each
-----------------------------------
数据交互 ajax
表单几乎没人用了
提交以后自动刷新(整个页面)
form
action 提交地址
默认不写提交到本地(当前页面)
如果写http,走的是http写,不写走本地
method 传输方式
get 地址栏提交 不安全 32k
post 浏览器内部 相对安全 1G
$.ajax({
url:'地址',
data:{
参数:xxx,
参数:xxx
},
type:'POST/GET',
success:function(str){ //成功回调函数
alert(str);
},
error:function (err){ //失败回调函数
alert(err);
}
});
ajax交互
填写地址
返回结果
解析结果
展示数据