JQuery Basic Features Quick Walkthrough
jQuery Basic Quick Features
2023-09-11 14:16:57 时间
1. Basic Selectors
-
$('p')—Accesses all the paragraph elements in the HTML file
-
$('div')—Accesses all the div elements in the HTML file
-
$('#A')—Accesses all the HTML elements with id=A
-
$('.b')—Accesses all the HTML elements with class=b
2. Applying CSS to Elements
$('div').addClass('highlight');
3. Some basic selection APIs
// select all the elements that contain the text Life $('span:contains(Life)').addClass('highlight'); $('div:odd').addClass('highlight'); $('div:even').addClass('boundary'); $('p:eq(1)').addClass('linkstyle');
4. Obtaining the HTML of an Element
alert($('p').html());
5. Changing the Content of a DOM Node
$('#textId').text('some text content');
$('p').html('<b>We can create Rich Internet Applications </b><br/>by making AJAX requests');
6. Creating a DOM Node on the Fly
1) Inserts the specified content at the beginning of the selected element and returns a jQuery object
$('p').prepend('<h2> Power of selectors </h2>');
相关文章
- jquery 调用点击事件
- js/jquery倒计时发送验证码按钮
- jQuery Custom Selector JQuery自定义选择器
- 图片延迟加载并等比缩放,一个简单的JQuery插件
- jQuery操作Form表单元素
- JQuery 插件开发
- JQuery模板插件jquery.tmpl-动态ajax扩展
- jquery访问ashx文件示例
- jQuery图片延迟加载插件:jquery.lazyload
- jQuery UI 实例 - 移除 Class(Remove Class)
- jQuery UI 实例 - 日期选择器(Datepicker)
- jQuery UI 实例 - 选择(Selectable)
- jQuery必知要点(一)
- jquery升级到新版本报错[jQuery] Cannot read property ‘msie’ of undefined错误的解决方法(转)
- jQuery/javascript实现全选全不选
- 白学jquery Mobile《构建跨平台APP:jQuery Mobile移动应用实战》连续7-电话问卷调查
- Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中
- jquery案例3——jq隔行换色