Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does jQuery.add( ) work in jQuery?
If you want to add element to an existing group of elements, then use the add() method.
|
S.No |
Parameter |
Description |
| 1. |
element |
Set the element, a jQuery object, one or more than one elements or HTML snippet, which you want to add to the existing group of elements |
| 2. |
context |
This parameter is optional. It sets the point at which the selector expression begins matching. |
Example
You can try to run the following code to learn how to work with jQuery.add() method −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("h1").add("p").css("background-color", "gray");
});
</script>
</head>
<body>
<h1>Tutorialspoint</h1>
<p>Text Tutorials for free.</p>
<span>Video Tutorials for free.</span>
</body>
</html>Advertisements