JQuery对元素的常用操作
2015-09-18 16:13
501 查看
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采用连缀写法实现的折叠菜单效果
- 使用jquery-combobox实现select下拉框多选之后,如何将下拉框的值传给input隐藏域
- jquery.validate.js实例演示
- jQuery插件Flot的介绍
- jquery.validate.js实例演示
- jquery效果
- jquery.validate使用说明及注意事项
- jquery 小知识点
- jQuery插件 -- Form表单插件jquery.form.js
- Jquery Ajax表单提交插件jquery form用法
- jquery扩展的radio和checkbox前端调用方法
- jquery扩展的easyui-checkbox控件
- 通过 ES6 Promise 和 jQuery Deferred 的异同学习 Promise
- jQuery之简单的表单验证
- jQuery多选下拉框 multiselect 的使用
- 在jquery中使用checkbox控件标签的隐藏和显示
- 一段jquery代码,保存
- jQuery设置和获取HTML、文本和值
- 全自动遮罩层插件layer2.0版本发布(可传参),兼容IE7以上
- jQuery 表单验证插件——Validation(基础)