开发者

Mootools element returning null

开发者 https://www.devze.com 2023-01-01 07:13 出处:网络
I have this HTML/PHP <input name=\"add to list\" class=\'fncAdd\' id=\'moodal_close\' value=\"add to list\" onclick=\"cajaxUpdateCartProduct(\'<?= $value->id ?>\', \'quantity_<?= $valu

I have this HTML/PHP

<input name="add to list" class='fncAdd' id='moodal_close' value="add to list" onclick="cajaxUpdateCartProduct('<?= $value->id ?>', 'quantity_<?= $value->id ?>', '<?= $this->sitePfx ?>/cart/');" type="button">

In my javascript 开发者_开发百科I have

$('moodal_close').addEvent('click', function(){
        alert("1");
    });

In my firebug console the only response I get is

$("moodal_close") is null


Are you trying to add the event before the element is created? You might try:

window.addEvent('domready', function() {
    $('moodal_close').addEvent('click', function(){
        console.log('sup');
    });
});


Your input tag should have a name of "moodal_close" instead of "add to list"

0

精彩评论

暂无评论...
验证码 换一张
取 消