JQuery Basic Features Quick Walkthrough

简介: 1. Basic Selectors $('p')—Accesses all the paragraph elements in the HTML file $('div')—Accesses all the div elements in the HTML file...

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>');

 

目录
相关文章
|
1月前
|
XML 前端开发 JavaScript
SAP Fiori Launchpad Custom Fields tile 里的 ABAP 语法高亮显示
SAP Fiori Launchpad Custom Fields tile 里的 ABAP 语法高亮显示
13 0
|
6月前
如何使用 Guided Development 给 Fiori Elements List Report 的工具栏添加自定义按钮试读版
如何使用 Guided Development 给 Fiori Elements List Report 的工具栏添加自定义按钮试读版
33 0
SAP UI5 Simple form rendering
Created by Wang, Jerry, last modified on Mar 05, 2016
115 0
SAP UI5 Simple form rendering
when is this.oModel in sap-ui-core.js initialized for navigation working
Created by Wang, Jerry, last modified on May 21, 2015
72 0
when is this.oModel in sap-ui-core.js initialized for navigation working
SAP UI5 control id generation by jQuery
Created by Wang, Jerry, last modified on May 21, 2015
105 0
SAP UI5 control id generation by jQuery
|
JavaScript API
[jQuery]25 Highly Useful jQuery Cheat Sheets For Web Developers
1. jQuery 1.2 Cheat-sheet [PNG]   2. jQuery 1.2 Cheat Sheet v1.0 [PDF] 3. jQuery 1.3 Cheatsheet [PDF] 4.
1538 0
|
JavaScript 前端开发 Python