how to get label value in javascript?

Today, We want to share with you how to get label value in javascript.In this post we will show you set labels value in javascript, hear for How to Assign or Set Value Dynamically to a Label using JavaScript? we will give you demo and example for implement.In this post, we will learn about jQuery calculate sum of values in all text fields with an example.

Read Also:  jquery get hidden field value

how to get/set labels for attribute value in javascript

Example 1:

//js code
labelText = $("#productCode").text()

//HTML code
<label id="productCode" for="male">Male</label>

Using JavaScript innerHTML Property

<script>
    document.getElementById('productCode').innerHTML = 'P0087755456';
</script>

Example 2: need to use .innerText
Using JavaScript innerText property

document.getElementById('*productCode').textContent

//HTML Code

<label id="*productCode" for="*tamilrokers4">
All hell.
<span class = 'pstej'></span>

Track label Property

Example 3:

var x = document.getElementById("productCode").label;

//OR Set

document.getElementById("productCode").label = "P9825650008";

I hope you get an idea about Label value to javascript variable.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.