I have this code on my site. The idea is to hide a specific class when a specific select box value is selected.
This is my code
$(document).ready(function(){
var txt = 'Marketing';
$("div.ginput_container select#input_3_1 option").each(function(){
if($(this).val()==txt){
$('.mar').hide();
}
});
});
The result I'm getting is .mar class being hidden as soon as the page is loaded. I can't see the error, I have also tryied with
var num = 1
but I have the same issue.
$("#input_3_1 option"). Also, why are you using.eachon a single element?$(this).val()exactly the same? As far as case? If it'smarketinginstead ofMarketingit will not work..marif any of the options has the valueMarketing, you're not just checking the selected option.