Reputation: 2229
I have a link below and will like to read the value "Electric" and store it in a variable
<a title="This is cool" id="lnkTranslate">Electric</a>
I tried the code below but no luck. Any ideas please?
var languageToConvertTo = $('#lnkTranslate').val($(this).html());
Upvotes: 0
Views: 16
Reputation: 475
Use the .text() function like so..
var languageToConvertTo = $('#lnkTranslate').text();
Upvotes: 1
Reputation: 3112
.val()
is used to get the value of input
tags. .text()
will give you the text between the opening and closing tags -
var languageToConvertTo = $('#lnkTranslate').text();
Upvotes: 0