Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 两个ID对应一个函数_Jquery_Joomla_Scroll - Fatal编程技术网

Jquery 两个ID对应一个函数

Jquery 两个ID对应一个函数,jquery,joomla,scroll,Jquery,Joomla,Scroll,我有一个具有滚动功能的按钮,我想添加另一个具有相同功能的按钮。我能做这个吗? 这是php <?php if($this->API->modules('cart')) : ?> <div id="btnCart" data-url="index.php?lang=<?php echo $lang; ?>&amp;tmpl=cart"><strong>Cart</strong></div&g

我有一个具有滚动功能的按钮,我想添加另一个具有相同功能的按钮。我能做这个吗? 这是php

<?php if($this->API->modules('cart')) : ?>
            <div id="btnCart" data-url="index.php?lang=<?php echo $lang; ?>&amp;tmpl=cart"><strong>Cart</strong></div>
            <?php endif; ?>


是的,您可以。。。但是你必须使用类来实现这一点。。。因为ID应该是唯一的。。。和
document.id('gkPopupCart')
。。。这是jquery吗??我在这里遗漏了什么吗..谢谢快速回答-我只需要一个重复的按钮,比如“btnCart”。这是原始代码,他工作得很完美。我不知道怎么复制这个按钮。对不起,我的英语。这将使另一个按钮时,网页包含它是放在服务器上,然后检索
// cart button
    if(document.id('gkPopupCart')) {
        var btn = document.id('btnCart');

        window.addEvent('scroll', function(e) {
            var scroll = window.getScroll().y;
            var max = document.id('gkMainWrap').getSize().y;
            var final = 0;
            if(scroll > 70) {
                if(scroll < max - 122) {
                    final = scroll - 50;
                } else {
                    final = max - 172;
                }
            } else {
                final = 20;
            }
            btn.setStyle('top', final + "px");
        });
 <? if($this->API->modules('cart')) {
 echo "<div id='btnCart' data-url='index.php?lang=$lang&amp;tmpl=cart'> 
       <strong>Cart</strong></div>";} ?>