mootools html和css操作帮助

时间:2010-05-25 15:02:08

标签: javascript mootools dom-manipulation

我有以下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成为{{1}的链接}}

任何帮助都会很棒

1 个答案:

答案 0 :(得分:0)

这应该隐藏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');
    });

});