jQuery对元素常用操作
1.redio checkbox
$('input:radio[name=""][value=""]').prop('checked', true); //初始化
$('input:radio[name=""][value=""]').prop('checked', true);
2.select
$('#select option[value="0"]').attr("selected",true); //初始化
3.事件
$('#select').trigger("change"); //触发change事件
4.选择
$('#select').nextAll('select'); //id为select的后续的所有select兄弟元素
$('#select').nextAll('select')[0];//id为select的后续的所有select兄弟元素的第一个
$('#select').nextAll();//id为select的后续的所有兄弟元素
$('#select').next(); //下一个兄弟元素
$('#select').next('select');//下一个select兄弟元素
$('#select').find('option[value=""]') //
//ajax
$.ajax({
type:"POST",
async: false,
data:{'isLoad':'-1'},
url:"",
dataType:"json",
success:function(json){
$.each(json,function(index,comment){
//alert(comment['']);
//alert(comment.**);
});
}
});
动态加载JS文件的三种方法
http://www.jb51.net/article/42942.htm
js 获取项目的根目录
var root = {
getRootPath:function () {
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPath = curWwwPath.substring(0, pos);
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
return projectName;
}
}
var base = root.getRootPath();
加载页面并执行JS
$("#storeContainer").load("url",function(html){
$.getScript("*.js",function(){});
});
JQuery对元素的常用操作
最新推荐文章于 2018-12-23 14:14:19 发布