【问题标题】:How to check disabled select element and I want to change opacity of disabled element by checking it如何检查禁用的选择元素,我想通过检查来更改禁用元素的不透明度
【发布时间】:2017-01-13 10:43:51
【问题描述】:
$_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选择图像时应用隐藏。 我想检查它,然后想在禁用元素中添加不透明度,直到未启用选择选项。 非常感谢。请随时为开发人员提供建议。每条建议对我来说都很有价值。

【问题讨论】:

    标签: javascript jquery html css magento-1.9


    【解决方案1】:

    使用css 样式。你可以这样做。

    select option:disabled{
        opacity: 0;
     }
    

    对于选择元素

    select:disabled{
        opacity: 0;
    }
    

    【讨论】:

    • 谢谢,但它仍然无法正常工作。选择已禁用但未应用不透明度。
    • 这是一个选择标签。
    • 谢谢,兄弟,它对我有用 :-) 无需检查 js 和 jquery 东西的简短而简单的方法。
    【解决方案2】:

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

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

    请注意,如果您依赖此方法,您还需要以编程方式禁用它,因为如果 JS 被禁用或不受支持,您将被禁用选择卡住。

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

    【讨论】:

      猜你喜欢
      • 2018-07-10
      • 2016-10-09
      • 2016-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-18
      • 1970-01-01
      • 2019-01-02
      相关资源
      最近更新 更多