如何检查禁用的 select 元素,我想通过检查它来更改禁用元素的不透明度

How to check disabled select element and I want to change opacity of disabled element by checking it

$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
    <dt><label class="required"><em>*</em><?php echo Mage::helper('catalog')->__($_attribute->getLabel()) ?></label></dt>
    <dd <?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
        <div class="input-box">
            <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
                <option><?php echo $this->__('Choose an Option...') ?></option>
              </select>
          </div>
    </dd>
    <?php endforeach; ?>
  </dl>
 <script type="text/javascript">
    var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>,   <?php echo $this->getProductsStockStatus()?>);
    var ProChildData = <?php echo $this->getProductsStockStatus()?>;
   </script>

这是一个模板的代码,当没有图片通过外部js select 时应用隐藏。 我想检查它,然后想在禁用元素中添加不透明度,直到 select 选项未启用。 感谢 advanced.Feel 免费提供建议 devs.Every 建议对我来说很有价值。

使用css风格。你可以这样做。

select option:disabled{
    opacity: 0;
 }

选择元素

select:disabled{
    opacity: 0;
}

您可以根据需要保持禁用状态,然后在提交表单之前移除禁用属性。

$('#myForm').submit(function() {
    $('select').removeAttr('disabled');
});

请注意,如果您依赖此方法,您还需要以编程方式禁用它,因为如果禁用或不支持 JS,您将陷入禁用状态 select。

$(document).ready(function() {
    $('select').attr('disabled', 'disabled');
});