Home jQuery How do I find the value of my tag value?

How do I find the value of my tag value?

by Shahriar Sagor
How do I find the value of my tag value

Hi Dev’s, Now today in this blog, I will show you how to get the tag value or any element content by using jquery. Now here we can get the tag value or element content from a selected tag. Here i will show you How do I find the value of my tag value?

So we can get tag value in html by using jquery then also by use bellow solution. So Many ways to we can get html tag value or element content.

Solution 1 : How to Select a tag of ‘p’ and display tag value ?
$('p').html();
Solution 2 : How to Select tag has a class name of “test” and display its value?
$('.test').html();
Solution 3 : How to Select tag has a id name of “test” and display its value ?
$('#test').html();
Full Example
<html>
<head>
    <title>Get Tag Value or Element in jQuery</title>
 
    <script type="text/javascript" src="jquery-1.3.2.js"></script>
 
</head>
<body>

    <h1>Get Tag Value or Element in jQuery </h1>

    <p>
        This is example 1
    </p>
	
    <div class="myClass">
        It is class='myClass'
	</div>
	
    <div id="myId">
        This is id='myId'
    </div>

    <script type="text/javascript">
 
        $(document).ready(function(){
            var $tag = $('p').html();
            alert($tag);
    
            var $tag = $('.myClass').html();
            alert($tag);
    
            var $tag = $('#myId').html();
            alert($tag);

        });

    </script>
</body>
</html>

Read Also : Laravel Ajax Image Upload With Intervention Package

I hope it will help you. Also you can follow us on Facebook.

close

You may also like