Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

Related documents


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 2 jQuery() Function  Jquery Selectors  Element Selector  $(‘elementname’)  ID selector  $(‘#id’)  Class selector  $(.class)  Attribute selector  Attribute name - $(‘*attributename+’)  Attribute value - $(‘*attributename+=“value”’) 4 b) Source : https://www.tutorialsteacher.com/jquery iquery-selectors paragraph span span div div $(‘div’) img src div This is paragraph aoa $('#myDivi') is paragraph. <span></span> </div> <div id="myDiv2"> <img src="~/home.png” /> Select : element . . . <p id="prg. $(#prg2')—> This is paragraph. 1a #Id </p> </body> SS Mu Mune cee ey Matas Descripti 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) 9 <script ="jquery.min.js"> </script> <script> $(document).ready(function () { $( ) .append( $( ) .append( }); </script> <style> div{ : lpx solid; : Ilpx dashed; </style> </head> <body> <div> <p></p> <p></p> </div> <p></ p> <div></div> </body> </html> Example 1 G@ @ 127.0.0.1:5500/JQUERY/jqi-html bod <body> <div> <p></p> <p></p> </div> <p></p> <div></div> </body> </html> This is div. Example 2 <body> <hl>Demo: jQuery attr() method</h1> <button id="btnDivStyle">Get div class</button> ="btnPStyle">Get p Style</button> </br></br> <button <div> This is div. </div> <p ="Tont-size:16px; font-weight: bold"> This is paragraph. This is div. <p ="color: M@red"> This is paragraph. </p> </body> </htm15| aR} Demo: jQuery attr() method | Get div class || Get p Style | This is paragraph. This is paragraph. 16 Demo: jQuery attr() method Get div class || Get p Style | This is paragraph. This is paragraph. 127.0.0.1:5500 says yellowDiv <script> $(document).ready( function () { $('#id').click(function () {alert('Clicked a Button'); }); }); </script> Click Event 19 <script> $(document).ready( function () { $('#id').on('mouseenter mouseleave', function() { $(this).text( 'Mouse entered or left from the element' ); }); }); </script> Handling Multiple Events 20
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved