【问题标题】:mootools html and css maniplation helpmootools html 和 css 操作帮助
【发布时间】:2010-05-26 18:12:23
【问题描述】:

我有以下 HTML

<div class="goto_step3">
<a href="<?= $this->sitePfx ?>/cart/paypal/" id="js_checkout_now" class="arrow">Checkout &amp; Pay</a>
<? if($this->discountCodeErrorMessage): ?>
    <p class="error discountError"><?= $this->discountCodeErrorMessage ?></p>
<? endif; ?>
<div class="discountCode fncFixedHeight <?= $this->has_discount ? 'redeemed': ''; ?>">
<? if(!$this->has_discount): ?>
    <label for="inptdiscountcode">Enter discount code</label>
    <input class='fncInpDiscountCode' id="inptdiscountcode" type="text" name="discount_code" value="" />
<? else: ?>
    <? if(!(empty($this->discount['discount_message']))): ?>
    <?= $this->discount['discount_message']; ?>
    <? else: ?>
    Voucher code redeemed
    <? endif; ?>
<? endif; ?>

在 DomReady 上,我希望 mootools 制作 .discountCode display:none.goto_step3 p display:none ,单击链接时我希望 display:none 变为 display:block

任何帮助都会很棒

【问题讨论】:

    标签: javascript mootools dom-manipulation


    【解决方案1】:

    这应该隐藏 dom 就绪的元素,并在单击链接时使它们可见。

    window.addEvent('domready', function() {
    
        // you can pass multiple selectors to $$ each separated with a comma
        $$('.discountCode, .goto_step3 p').setStyle('display', 'none');
    
        $$('.goto_step3 a').addEvent('click', function() {
            $$('.discountCode, .goto_step3 p').setStyle('display', 'block');
        });
    
    });
    

    【讨论】:

    • this 在 click 函数的上下文中绑定到已经可见的 A... 应该是 this.getNext().setStyle("display", "block"); 以定位 P
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多