How to get Elements of HTML using id and class in JQuery

How to get the element from the html file using their id and class property. In my previous article we have already get the html element from their id property. But in this article we will get the element from their class name. Lets take a simple example to demonstrate the article.

<%@ Page Language="C#" %>

<!DOCTYPE html>
<html xmlns="">
<head runat="server">
<script src="Scripts/jquery-1.10.2.js"></script>
$('#Button1').click(function () {
var firstdiv = $('#first').html();

var getclass = $('.test').html();



    <form id="form1" runat="server">
    <div id="first" style="border: 1px solid #009900; padding: 10px">
    Welcome to my website

<div style="border: 1px solid #00ffff; padding: 10px" class="test">

Get This Text By class
<input id="Button1" type="button" value="Get Element By Id" />
When we click on the button a alert message have to generate with some message. Using html () method we can get the text of the tag.


Post a Comment