Professional Documents
Culture Documents
1. Find all h1 elements that are children of a div element and apply a background color to them.
Sample Data :
<body>
<h1>abc</h1>
<div>
<h1>div-1</h1>
<h1>div-2</h1>
</div>
<h1>xyz</h1>
</body>
<body>
<form name='demo_form'>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
<body>
<form action="">
<input type="radio" name="sex" value="male" checked>Male<br>
<input type="radio" name="sex" value="female">Female
</form>
</body>
5. Write a jquery code to get the second element (li) from the selection
<body>
<ui>
<li>Html Tutorial</li>
<li>Mongodb Tutorial</li>
<li>Python Tutorial</li>
</body>
6. Write a jquery code to add a <b> tag at the beginning of the list item, containing the index of the list
item
<body>
<ui>
<li>Html Tutorial</li>
<li>Mongodb Tutorial</li>
<li>Python Tutorial</li>
</body>
Output
• 0: Html Tutorial
• 1: Mongodb Tutorial
• 2: Python Tutorial
7. Write jquery code to change the hyperlink and the text of an existing link
Clicked on – P
Clicked on – DIV
Clicked on – INPUT
9. When the button is clicked, please output the number of li elements present on the HTML document
<body>
<ul>
<li>List - 1</li>
<li>List - 2</li>
<li>List - 3</li>
</ul>
<button>Display the number of li elements in console</button>
</body>
sample output - 3