JQuery Select All Elements

From CoderLearner
Jump to: navigation, search

Description

Use the * to access all the HTML elements.

Example 1

Assign text's color to blue for all elements by using the * for all elements.

<html>
	<head>
		
		<title>Select ALL</title>
		<script type="text/javascript" src="jquery.min.js">
		</script>
		<script type="text/javascript" language="javascript">
			$(document).ready(function() {
				$("*").css('color','blue');
			});
		</script>
	</head>
	<body>
		<div>GOod</div>
		<span>Bad</span>
		<ul>
			<li>List 1</li>
			<li>List 2</li>
		</ul>
	</body>
</html>

Example 2

All elements contain the classs myblue will assign the text color to blue.

<html>
	<head>
		
		<title>All Element with Class</title>
		<script type="text/javascript" src="jquery.min.js">
		</script>
		<script type="text/javascript" language="javascript">
			$(document).ready(function() {
				$('.myblue').css('color','blue');
			});
		</script>
	</head>
	<body>
		<div class="myblue">GOod</div>
		<span class="myblue">Bad</span>
		<ul>
			<li>List 1</li>
			<li>List 2</li>
		</ul>
	</body>
</html>

Assign HTML element

All p elements will assign the text color to blue.

<html>
	<head>
		
		<title>All P Element</title>
		<script type="text/javascript" src="jquery.min.js">
		</script>
		<script type="text/javascript" language="javascript">
			$(document).ready(function() {
				$('p').css('color','blue');
			});
		</script>
	</head>
	<body>
		<div class="myblue">GOod</div>
		<span class="myblue">Bad</span>
		<ul>
			<li>List 1<p>lost it</p></li>
			<li>List 2</li>
		</ul>
                <p>go to school</p>
	</body>
</html>


<seo metagenerator="jquery tutorial" title="Jquery/Ajax" metakeywords="jquery greater,jquery gt, jquery lt, less then, odd jquery,jquery find element, even jquery,jquery event, jquery mouse click, jquery double click, jquery hover, jquery string, jquery array, jquery button, jquery attriubtes" metadescription="jquery button, jquery attriubte, jquery example, jquery tutorial, jquery sample"/>