Reputation: 4009
So I am working with Weebly as a CMS for one of my clients. I am having to change the content for an input field however by default it has no value. The code for the input is as follows
<input class="wsite-form-input name="apply-code" placeholder="Enter Code">
I am trying to change the content of this with some JavaScript but not sure about the best way to go about this. I would normally just create a variable and then change the value of that variable but seeing as there isn't one present I don't think I can do it.
Could I change the inner text?
Thanks
Upvotes: 1
Views: 50
Reputation: 2121
you can easily change the input element's value as like this
var name="Put your name here";
$('input.wsite-form-input').val(name);
Upvotes: 1
Reputation: 56
Yes, it's possible, something like:
function changeInputValue(textValue){
document.getElementsByName("apply-code")[0].value=textValue;
}
Upvotes: 0
Reputation: 2035
First of all, you are missing a closing apostroph after .wsite-form-input
, and to give it a value, you could do the following:
$(".wsite-form-input").val("Your value here");
Upvotes: 1