Reputation: 125
Right now I have this code:
$(".categories").change(function(){
var target = $('.categories option:selected').val();
if(target == "Career")
$(".subcat").css( "display","inherit" );
else if(target == "Life Style")
$(".subcat2").css( "display","inherit" );
else if(target == "Do It Yourself")
$(".subcat3").css( "display","inherit" );
else if (target == "Other")
$(".subcat4").css( "display","inherit" );
});
however when I choose whatever category it only return the value as being "Career", and not anything else, even though I select other options. How do I fix it?
Upvotes: 1
Views: 23
Reputation: 67217
Try,
var target = $(this).val();
instead of
var target = $('.categories option:selected').val();
Upvotes: 1