php - jQuery get specific option tag selected values -
i have this,
<select id="customuser_id" name="customuser_id"> <option value="2" label="friends of friends">friends of friends</option> <option selected="selected" value="3" label="friends only">friends only</option> <option value="4" label="specific people">specific people</option> <option value="0" label="only me">only me</option> </select> i want value of selected option using jquery.
currently using onchange() event this,
$('#customuser_id').change(function(){ if(($(this).val()==2)){ $("#customwallpost3").text("only friends of friends can see this"); } else if(($(this).val()==3)){ $("#customwallpost3").text("only friends can see this"); } else if(($(this).val()==4)){ $("#customwallpost3").text("only people above can see this"); } else if(($(this).val()==0)){ $("#customwallpost3").text("only can see this"); } else{ $("#customwallpost3").text(""); } }); this working when alter alternative value, want selected alternative value this. in advance
not sure asking for...
i want selected alternative value this..
but selected alternative value, use
$('#customuser_id').val(); this gives selected value of <select> id customuser_id
updated
if want text of selected alternative can do
$("#customuser_id option:selected").text(); php javascript jquery html
No comments:
Post a Comment