首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对单个Jquery插件使用两个ids

对单个Jquery插件使用两个ids
EN

Stack Overflow用户
提问于 2013-02-02 13:56:23
回答 1查看 122关注 0票数 0

我正在尝试使用jquery的单个插件,并希望将相同的功能应用于两个不同的ids。

我如何实现这一点,它是一种下一步和前一步的功能,如果我们单击下一步,那么两个div都应该自动滚动。

如果你看到html,有两个相同id的div,我不应该使用,因为id应该是唯一的,如果我改变id,以及如何为相同的插件调用该id。

请求帮助

这就是我尝试过的。

代码语言:javascript
复制
stepcarousel.setup({
    galleryid: 'gallerya', //id of carousel DIV
    beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panel', //class of panel DIVs each holding content
    autostep: {enable:true, moveby:1, pause:3000},
    panelbehavior: {speed:300, wraparound:false, persist:false},
    defaultbuttons: {enable: true, moveby: 1, leftnav: ['images/left-arrow.png', 200, -30], rightnav: ['images/right-arrow.png', 10,  -30]},
    contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

div id="gallerya" class="stepcarousel" style="height:731px;">
                    <div class="belt">
                        <div class="panel" style="width:252px;">
                        <ul>
                        <li class="first leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/financial-analyst-interview-preparation.html" title=""> How to prepare for financial analyst interview?</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/external-training-programs-and-salary.html" title="">Are external training programs offered by company part of salary package?</a></li>
<li class="leaf"><a href="/preparation-for-an-interview/bank.html" title="">Bank Interview Preparation</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/prepare-for-campus-interview.html" title="">Best ways to Prepare for Campus Interview</a></li>
<li class="leaf"><a href="/preparation-for-an-interview/cognitive-abilities-tests" title="">Cognitive Abilities Test</a></li>
<li class="leaf"><a href="/preparation-for-an-interview/college.html" title="">College Interview Preparation</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/career-goals-in-job-interview.html" title="">Discussing career goals in a job interview</a></li>
<li class="leaf"><a href="/tools/dressing-tips" title="">Dressing up for Interview</a></li>
<li class="leaf"><a href="/top-100-questions/engg" title="">Engineering Interview Questions</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/favorite-job-destinations-in-india.html" title="">Favorite job destinations in India</a></li>
<li class="leaf"><a href="/top-100-questions/finance" title="">Finance Interview Questions</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/group-discussion-rules-for-interview.html" title="">Group Discussion Rules for Interview updated</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/dietician-interview-preparation.html" title="">How to Prepare for Dietician Job Interview</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/lab-technician.html" title="">How to Prepare for Lab Technician Interview?</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/pilot-interview-preparation.html" title="">How to Prepare for Pilot Interview</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/accounting.html" title="">How to Prepare for an Accounting Interview</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/insurance-agent-interview-preparation.html" title="">How to Prepare for an Insurance Agent Interview?</a></li>
<li class="leaf"><a href="http://www.jobzing.com/preparation-for-an-interview/how-to-answer-basic-interview-questions.html" title="">How to answer basic interview questions?</a></li>
                    </ul>
                        </div> 

<div id="gallerya" class="stepcarousel" style="height:160px;">
                    <div class="belt">
                        <div class="panel">
                        <ul>
                        <li>
                            <span><a href="http://www.jobzing.com/9779-project-manager.html"><b>Project Manager</u></b></a></span></span> <br />  
                            <span>A&amp;E Consulting</span><br />  
                            <span>Philippines </span>
                    </li>
                    <li>
                            <span><a href="http://www.jobzing.com/9779-project-manager.html"><b>Project Manager</u></b></a></span></span> <br />  
                            <span>A&amp;E Consulting</span><br />  
                            <span>Philippines </span>
                    </li>
                    </ul>
                        </div>  

Page that I am creating

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-02 14:44:58

你有没有尝试过这样的东西:

使用galleryid: 'galleryA'beltclass: 'beltA'panelclass: 'panelA'调用.setup一次。然后是galleryid: 'galleryB'beltclass: 'beltB'panelclass: 'panelB'

代码语言:javascript
复制
stepcarousel.setup({
    galleryid: 'galleryA', //id of carousel DIV
    beltclass: 'beltA', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panelA', //class of panel DIVs each holding content
    autostep: {enable:true, moveby:1, pause:3000},
    panelbehavior: {speed:300, wraparound:false, persist:false},
    defaultbuttons: {enable: true, moveby: 1, leftnav: ['images/left-arrow.png', 200, -30], rightnav: ['images/right-arrow.png', 10,  -30]},
    contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

stepcarousel.setup({
    galleryid: 'galleryB', //id of carousel DIV
    beltclass: 'beltB', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panelB', //class of panel DIVs each holding content
    autostep: {enable:true, moveby:1, pause:3000},
    panelbehavior: {speed:300, wraparound:false, persist:false},
    defaultbuttons: {enable: true, moveby: 1, leftnav: ['images/left-arrow.png', 200, -30], rightnav: ['images/right-arrow.png', 10,  -30]},
    contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

然后你的HTML就像这样:

代码语言:javascript
复制
<div id="galleryA" class="stepcarousel" style="height:731px;">
    <div class="beltA">
        <div class="panelA" style="width:252px;">
            <ul>
                <li></li>
                <li></li>
            </ul>
        </div> 
    </div>
</div>

<div id="galleryB" class="stepcarousel" style="height:160px;">
    <div class="beltB">
        <div class="panelB">
            <ul>
                <li></li>
                <li></li>
            </ul>
        </div> 
    </div>
</div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14659119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档