Reputation: 32798
I have the following:
<td class="ui-widget-content" style="width: 244px;">
<span id="refLink_9" class="refLink">
<input type="text" value="/C02E/Java-Notes-Classes1" size="30" name="item.Link" id="Link_9"
class="wijmo-wijtextbox ui-widget ui-state-default ui-corner-all">24</input>
</span>
</td>
I tried to set the value of the input as follows. But it's not working.
var linkValue = 25;
$(".refLink input").html(linkValue);
Can anyone point me to what's wrong?
Upvotes: 1
Views: 249
Reputation: 126042
var linkValue = 25;
$(".refLink input").val(linkValue);
.val
is for setting the value of each element (typically used for form fields), and .html
is used to set the html content of each element.
Also, per @DavidThomas' comment above, your input should look more like this:
<input type="text" value="/C02E/Java-Notes-Classes1" size="30" name="item.Link" id="Link_9"
class="wijmo-wijtextbox ui-widget ui-state-default ui-corner-all" value="24" />
Upvotes: 4
Reputation: 7019
To begin with:
<input type="text" value="/C02E/Java-Notes-Classes1" size="30" name="item.Link" id="Link_9" class="wijmo-wijtextbox ui-widget ui-state-default ui-corner-all">24</input>
is not standard practice. Input
isn't meant to have an end tag and so the value of a textbox
is provided via it's value
attribute. Thus, the textbox
will be set to /C02E/Java-Notes-Classes1 while 24 will just be plain text.
Answering your question, using
$(".refLink input").val(linkValue);
will allow you to set the value of the textbox
, thus essentially over-writting /C02E/Java-Notes-Classes1 rather than 24 which I'm assuming you expect as the behaviour.
Upvotes: 0