Changing Values ​​in Javascript

I am new to Javascript and I am trying to learn by doing a webpage. So this is a button, and when you click on it, it gets a child with id oddsInput. I can not change the values

function checksettings(payout) {
$('#oddsPayout').click();
var iodds = $('#oddsInput');
iodds.value = payout;
// $('glyphicon glyphicon-ok btn btn-success').click();
}

checksettings(2)
+4
source share
2 answers

This is because it $('#oddsInput')is a jQuery object . It has no property value.

Access the first DOM element in a jQuery object:

iodds[0].value = payout;
// or
$('#oddsInput')[0].value = payout;

or, since this is a jQuery object, use the method .val():

iodds.val(payout);
// or
$('#oddsInput').val(payout);
+2
source

Try

$('#oddsInput').val(payout);
0
source

Source: https://habr.com/ru/post/1619601/


All Articles