I have 2 radio buttons, the second is with input field. I need to get the value of the selected, and in case of the second, value from the input field. The thing is, that when the second button is selected, its input value is empty until user types something there. As a result, I have always empty field.
The markup and code is below
<input id="x" type="radio" name="re" value="Undefined" checked>No limit
<input id="y" type="radio" name="re" value="limit">Limit
<input id="y-input-radio" type="number" min="1" max="20" placeholder="Up to 20"/>
//tweet limit
$('input[type="radio"]').on('click', function(){
var value = $(this).val();
if(value === 'limit'){
var tweetLimit = document.getElementById('y-input-radio').value;
console.log(tweetLimit); //returns 0 cos its still empty
}
});
I cheked setTimeout but I am not sure how to implement it and maybe there is another solution