Reputation: 1181
I don't understand why the value isn't changing for this input from the website. I've tried this jquery code:
$('input[type=text].u').val('http://website/');
But it isn't changing or working:
https://jsfiddle.net/cq4e02yj/
Also I've tried to trigger click the button but that isn't working either.
-Thanks
Upvotes: 0
Views: 231
Reputation: 4953
Here's a first working solution. You are missing the quotes around type="text". Hope it helps.
$(document).ready(function() {
$("#myButton").click(function(){
$('input[type="text"]').val('http://website/');
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<center><input name="u" id="input" size="60" class="textbox" value="http:/s/" type="text"><input value="Change My IP Address" id = "myButton" class="button" type="submit"></center>
Here's a second solution without clicking on button.
$('input[type="text"]').val('http://website/');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<center><input name="u" id="input" size="60" class="textbox" value="http:/s/" type="text"><input value="Change My IP Address" id = "myButton" class="button" type="submit"></center>
Upvotes: 4
Reputation: 24965
The input does not have a class of 'u'. .u
is a class selector. If you put that on the class then your fiddle works.
If you want to keep the selector the same...
$('input[type=text].u').val('http://website/');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<center><input name="u" id="input" size="60" class="textbox u" value="http:/s/" type="text"><input value="Change My IP Address" class="button" type="submit"></center>
Upvotes: 0