JQuery Access Class Attribute

From CoderLearner
Jump to: navigation, search

jQuery Access HTML elements by class attribute

jQuery retrieve or assign content to HTML elements by using the class attribute. The class attribute specifies the element to be a member of one or more classes. Access the class attribute with the . (dot) and the class attribute name.

  • <p class="dogg">....</p>


Access the class attributes.

$("div.myclass").html("Great and wonderful");

Example 1

<!DOCTYPE html>
		<title>Access ID</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="jquery.min.js">
				$("div.myclass").html("Great and wonderful");
                <div class="myclass">Love and love!</div>
		<p class="myclass">Good old day!</p>

<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"/>