我正在尝试使用单个jquery插件,我想将相同的功能应用于两个不同的ID。
我如何实现这一点,它是一种下一个和以前的功能,如果我们点击下一个,那么两个div应该自动滚动..
如果你看到html有两个相同id的div,我不应该使用,因为如果我更改id,id应该是唯一的,如何为同一个插件调用该id。
请求帮助
这是我尝试过的。
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&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&E Consulting</span><br />
<span>Philippines </span>
</li>
</ul>
</div>
答案 0 :(得分:0)
你有没有试过这样的事情:
使用.setup
,galleryid: 'galleryA'
和beltclass: 'beltA'
致电panelclass: 'panelA'
一次。然后再次使用galleryid: 'galleryB'
,beltclass: 'beltB'
和panelclass: 'panelB'
。
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就像这样:
<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>