How to get selected option value using jquery?

To get selected option value of select HTML tag use option:selected property.
<select id=”selectid”>

<option value=’1′>One</option>

<option value=’2′>Two</option>

<option value=’3′>Three</option>

<option value=’4′>Four</option>

</select>

<script>

$(‘#selectid option:selected’).attr(‘value’);

</script>

Very BadBadAverageGoodExcellence (3 votes, average: 4.67 out of 5)
Loading...

How to find radio button selection using jquery?

/*****************************************STYLE SHEET****************************************/

<style>
.border-right{border-right:1px solid #EEE; background-color:FFF; cursor:pointer;}
.border-right:hover{background-color:#e7f1fa !important}
.hide-radio{ display:none;}
.selected-radio{background-color:#e7f1fa; font-weight:bold; }
.unselected-radio{background-color:#FFF;font-weight:normal;}
</style>

/*****************************************HTML****************************************/

<table style=”font-size:12px;”>
<tr>
<td class=”border-right”><input type=”radio” name=”time” value=”8hours” checked=”checked”/>8 hours</td>
<td class=”border-right”><input type=”radio” name=”time” value=”24hours”  class=”hide-radio”/>24 hours</td>
<td class=”border-right”><input type=”radio” name=”time” value=”48hours” class=”hide-radio”/>48 hours</td>
<td class=”border-right”><input type=”radio” name=”time” value=”3days” class=”hide-radio”/> 3 days</td>
<td class=”border-right”><input type=”radio” name=”time” value=”5days” class=”hide-radio”/> 5 days<br /></td>
<td class=”border-right”><input type=”radio” name=”time” value=”7days” class=”hide-radio”/>7 days</td>
<td class=”border-right”><input type=”radio” name=”time” value=”14days” class=”hide-radio”/>14 days<br /></td>
<td class=”border-right”><input type=”radio” name=”time” value=”1month” class=”hide-radio”/>1 Month<br /></td>
</tr>
</table>

/*****************************************JAVASCRIPT****************************************/

$(function(){

$(“.border-right”).click(function(){

$(“input[name=’time’]”).addClass(“hide-radio”);
$(“.border-right“).removeClass(“selected-radio”);
$(this).addClass(“selected-radio”);
$(this).find(“input[type=’radio’]”).removeClass(“hide-radio”);
$(this).find(“input[type=’radio’]”).attr(“checked”,true);
});

});

Very BadBadAverageGoodExcellence (1 votes, average: 3.00 out of 5)
Loading...

How find which radio button is selected using jquery

<form>

<input type=”radio” id=”ratingPoint4″ name=”ratingPoint” value=”1″ />

<input type=”radio” id=”ratingPoint4″ name=”ratingPoint” value=”2″ />

<input type=”radio” id=”ratingPoint4″ name=”ratingPoint” value=”3″ />

<input type=”radio” id=”ratingPoint4″ name=”ratingPoint” value=”4″ />

<input id=”survey-submit” type=”submit” class=”survey-button aui-button” value=”Post”/>

</form>

<script>
jQuery(function(){
jQuery(“#survey-submit”).click(function(){
jQuery(“input[name=ratingPoint]”).each(function(){
if(jQuery(this).is(‘:checked’))
{
alert(jQuery(this).val());
}
});
});
});
</script>

Very BadBadAverageGoodExcellence (1 votes, average: 5.00 out of 5)
Loading...