I have an element:
#credit-card{:style => user.has_stripe_customer_id? ? "display:none" : "display:block"}
.input
= text_field_tag :credit_card_number, params[:credit_card_number], :class => "field"
.actions
= f.submit("Buy Gift")
How should I write a jQuery selector to check if #credit-card is in “display:none” or not? I tried
if($('#credit-card').hasClass('display:none')) {
$('input[type=submit]').attr('disabled', true);
}
But it doesn’t work.
Thank you.
You could use the
:hiddenpseudoselector (if it is specific enough):Or, if that’s not specific enough, you could examine the CSS
displayproperty using.css: