4

I'm new to Javascript and I'm trying to learn by tinkering with a webpage. So it is a button and when you click it, it gains a child with the id oddsInput. I cant get the values to change

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

checksettings(2)

2 Answers 2

2

It's because $('#oddsInput') is a jQuery object. It doesn't have a value property.

Either access the first DOM element in the jQuery object:

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

or, since it's a jQuery object, use the .val() method:

iodds.val(payout);
// or
$('#oddsInput').val(payout);
Sign up to request clarification or add additional context in comments.

Comments

0

Try

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.