why i cant get value of label with jquery and javascript? -


i have usual label

<label class="mytxt"  style="color: #662819;" id ="telefon"></label> 

i setting value this:

document.getelementbyid('telefon').innerhtml = userdetails.phone; 

after label has value "123".

in pagesource, have label without setted value inside "><" see output alright:

pagesource: <label class="mytxt"  style="color: #662819;" id ="telefon"></label> 

my problem when get value. tried standards like:

value = $("#telefon").val();  document.getelementbyid('telefon').value  

nothing works, value "not defined". why so, if see in browser?

you need text() or html() label not val() function should not called label instead used values of input text or checkbox etc.

change

value = $("#telefon").val();  

to

value = $("#telefon").text();  

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -