Skip to content

Commit

Permalink
q4 added
Browse files Browse the repository at this point in the history
  • Loading branch information
purusottam32 committed Dec 8, 2024
1 parent 1c60834 commit 74dfdc9
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions ASSIGNMENT-3/Q4/q4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!-- Write a jQuery program with two buttons: one button labeled 'Fetch Text' to retrieve
and display the text content of a <p> element using an alert, and another button labeled
'Fetch HTML' to retrieve and display the HTML content of a <div> element using an
alert. -->






<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Q 4</title>
<style>
.content{
margin: 10px;
padding: 5px;
border: 2px solid black;
}
.button{
padding: 10px 20px;
margin: 10px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
}
</style>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.7.1.js"
integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"
></script>

<!-- pargraph and the div element -->
<p class="content" id="textcontent">This is the text conetent of the "p" element</p>
<div class="content" id="htmlcontent">
<p>This is the text conetent of the "div" element</p>
</div>

<button class="button" id="fetchtext">Fetch Text</button>
<button class="button" id="fetchhtml">Fetch HTML</button>

<script>
$(document).ready(function(){
$("#fetchtext").on("click",function(){
let fetext=$("#textcontent").text();
alert("Text content : "+fetext);
})
$("#fetchhtml").on("click",function(){
let fehtml=$("#htmlcontent").html();
alert("Html content : "+fehtml);
})
})
</script>
</body>
</html>

0 comments on commit 74dfdc9

Please sign in to comment.