How do I find the value of my tag value?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
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.

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.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →