Reputation: 6938
I am trying to give a border for select box through jquery. Although the border works for text fields, its not getting rendered for select box. However if i add this same property through firebug or so, it renders.. JS Fiddle : http://jsfiddle.net/bfcfQ/
<select name="signup_gender" id="form-field-select-1" class="signup_gender">
<option value="0"> Select Gender</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
<br>
<button class="test">Submit</button>
jQuery :
$(".test").click(function(){
signup_gender = $('select[name="signup_gender"]').val();
alert(signup_gender);
if(signup_gender==0){
$(".signup_gender").css("border","1px solid #ff0000 !important");
}
});
Is there a way to do :focus in css through jquery ??
Upvotes: 0
Views: 4504
Reputation: 3876
You're not selecting the correct element. You said $(".signup_usertype")
but you meant $(".signup_gender")
. See working Fiddle: http://jsfiddle.net/bfcfQ/1/
Upvotes: 2
Reputation:
Maybe you want an event handler for the element.
$('select#yourSelectID').focus(function() {
// javascript/jquery alteration on the element, ie:
$(this).css('background', '#ff0'); // will change the background to red
});
Upvotes: 0