javascript - 想要更新 magento 1.7.2 中的自定义选项文本

标签 javascript jquery css magento magento-1.7

enter image description here

检查自定义选项。我需要改变这个。 单击每个选项,显示价格 ([Add $200] 或 [Substract $50]) 的 div 应该得到 display none。 表示当您单击绿色时,相应的价格 block 不得可见,但红色和黄色价格 block 应该可见。

类似的,当你点击黄色的[subtract $50] 时一定不可见,但其他价格 block 应该可见

最佳答案

将下面的 jQuery 代码添加到 view.phtml。我已经使用默认的 magento 布局对其进行了测试。

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('ul.options-list li .product-custom-option').click(function(){
            var inputId = jQuery(this).attr('id');
            jQuery('ul.options-list li span.price-notice').css('display','block');              
            jQuery('ul.options-list li').removeClass('active');
            jQuery("#"+inputId).parent().addClass('active');
            jQuery('ul.options-list li.active span span.price-notice').css('display','none');   

        });
    });
</script>

希望对你有用!

关于javascript - 想要更新 magento 1.7.2 中的自定义选项文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20235868/

相关文章:

javascript - 如何从 Javascript 添加 CSS 样式

css - 哪种可打印元素比线性渐变更好用?

javascript - 如何使用 Service Worker 获取 json 数据并更新应用程序 shell

javascript - 使用 C# 后端运行 Angular/JavaScript

javascript - 将值保存在数组中(并覆盖每次更新)

html - 在元素中居中放置多个链接

html - 真气缺口: How do you get rid of a gap between IMG and surrounding content

javascript - Meteor "counts-by-room"导致模板无法加载的示例

jQuery Children() 更深入

javascript - jQuery ReplaceWith 未正确加载 div