jQuery: A Comprehensive Guide to Selectors, DOM Manipulation, and Event Handling, Exercises of Compilers

An overview of jQuery, a popular JavaScript library used for simplifying HTML document traversing, event handling, and animating webpage elements. It covers the use of jQuery selectors, methods for DOM manipulation, and event handling techniques. Students and developers can use this document as a reference for understanding the basics of jQuery and implementing it in their projects.

Typology: Exercises

2022/2023

Uploaded on 11/18/2022

ropela3873
ropela3873 🇨🇳

1 document

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
jQuery
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download jQuery: A Comprehensive Guide to Selectors, DOM Manipulation, and Event Handling and more Exercises Compilers in PDF only on Docsity!

jQuery

jQuery

 A rich client side Library to work Java script easily

 Implemented as a single .js file

 Selectors

 retrieve, manipulate, add and remove DOM elements

 Functions for event handling

 Easy to use AJAX functions

jQuery() Function

 While loading jQuery library, it adds a global function jQuery() in the scope of

window,

 window.jQuery() or jQuery() or $() or window.$() where $ is alias name of

jQuery

 To access the Document Object using jQuery Selector

 To find whether document is loaded $(document).ready();

 Ready takes a callback function as a parameter that is invoked once

document is ready.

 $(document).ready(function() { //write code here });

jQuery() Function

 Jquery Selectors

 Element Selector  $(‘elementname’)  ID selector  $(‘#id’)  Class selector  $(.class)  Attribute selector  Attribute name - $(‘attributename+’)  Attribute value - $(‘attributename+=“value”’)

jQuery() Selectors : By id

6 Source : https://www.tutorialsteacher.com/jquery/jquery-selectors

jQuery() Selectors : By attribute name

7 Source : https://www.tutorialsteacher.com/jquery/jquery-selectors

Methods- DOM manipulation

append() appends content at the end of element(s) that is mentioned by a selector. before() adds content (new or existing DOM elements) before an element(s) that is mentioned by a selector. after() Inserts content (new or existing DOM elements) after an element(s) that is mentioned by a selector. prepend() Insert content at the beginning of an element(s) that is mentioned a selector. remove() removes element(s) from DOM that is mentioned by selector. text() Get or set text content of the selected element(s)

Methods- HTML attr manipulation

attr()

read or change value of mentioned attribute of the element.

prop()

read or change value of mentioned property of the element..

html()

read or change content of the mentioned element..

text()

read or change text for the mentioned element

val()

read or change value of form field.

Methods- Event Handling

Click Event