Jump to: navigation, search

JQuery Access HTML Element

From w3cyberlearnings

Contents

jQuery Access HTML elements

jQuery uses to retrieve content from or assign content to HTML elements.

Syntax

$("p").html("something"); // assign
$("p").html(); // get 

$("div").html();

Note

You can append value to the end or assign value to the begining or the end of the HTML elements.

Example TRY-IT

<html>
	<head>
		<title>Basic Jquery</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="jquery.min.js">
		</script>
		<script language="javascript">
			$(document).ready(function(){
				alert($("p").html()); // get the HTML element content
				
				$("i").html("wonderful"); // assign the HTML element
			});
		</script>
	</head>
	<body>
		<h3>Hello Word</h3>
		<p>
			Everyone is <i>great</i>, 
			and, it is a <i>good</i> night.
			I can tell that.
		</p>
	</body>
</html>

Related Links


Navigation
Web
SQL
MISC
References