Skip to content

Commit dc6e9c3

Browse files
committed
Get Attributes - attr() | text() | html() 🚀
1 parent c3cd9da commit dc6e9c3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

jQuery/jQuery-HTML/get.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
6+
<script>
7+
$(document).ready(function () {
8+
$("#txtbtn").click(function () {
9+
alert("Text: " + $("#test").text());
10+
});
11+
$("#htmlbtn").click(function () {
12+
alert("HTML: " + $("#test").html());
13+
});
14+
$("#hrefbtn").click(function () {
15+
alert($("#googlelink").attr("href"));
16+
});
17+
});
18+
</script>
19+
</head>
20+
21+
<body>
22+
23+
<p id="test">This is some <b>bold</b> text in a paragraph.</p>
24+
25+
<p><a href="https://www.google.com/" id="googlelink" target="blank">Google.com</a></p>
26+
27+
<button id="txtbtn">Show Text</button>
28+
<button id="htmlbtn">Show HTML</button>
29+
<button id="hrefbtn">Show href Value</button>
30+
31+
</body>
32+
33+
</html>

0 commit comments

Comments
 (0)