Reputation: 2642
I have the following value 'testValue' in my javascript file
$('#testValue').val(RestServices.getValueCovid(response, 'TESTVALUE'));
In the html file I have
<input name="testValue" id="testValue" />
This works and displays the value on the webpage but it is in an input box.
I want to display it just as plain text using <p> <span> <div>
or whatever you suggest. The browser is IE8. I have tried getElementById and a few other ways but not working. Any suggestions welcome
Upvotes: 0
Views: 46
Reputation: 218960
First create your page element, for example:
<span id="testValueText"></span>
Then set the text of that element much in the same way you set the value of the <input>
:
$('#testValueText').text(RestServices.getValueCovid(response, 'TESTVALUE'));
A couple notes:
id
doesn't have to be what I specified here, it just has to be unique. If you're getting rid of the <input>
element then you can re-use the same id
to make it simpler.RestServices
twice, just fetch it once and store it in a variable. Then use that variable to populate the two elements.Upvotes: 1