I have this form with these inputs, I want to get the value that is inside the input of the selected radio button, example as in the image, I should get "bb".
Myhtml:
<label>Respostas:</label><divclass="input-group">
<span class="input-group-addon">
<input type="radio" name="respostacorreta">
</span>
<input type="text" class="form-control" id="pergunta1">
</div><!-- /input-group -->
<div class="input-group">
<span class="input-group-addon">
<input type="radio" name="respostacorreta">
</span>
<input type="text" class="form-control" id="pergunta2" >
</div><!-- /input-group -->
<div class="input-group">
<span class="input-group-addon">
<input type="radio" name="respostacorreta" >
</span>
<input type="text" class="form-control" id="pergunta3">
</div><!-- /input-group -->
My jquery so far, I'm just getting text from all fields:
<script>
$(document).ready(function(){
$('#btnenviarnoticia').click(function() {
var btn = $(this);
btn.button('loading');
var respostas = [$('#pergunta1').val(),$('#pergunta2').val(),$('#pergunta3').val()];
alert(respostas);
});
});
</script>