我正在尝试同时使用内容面板切换器 ( http://code.google.com/p/jquery-content-panel-switcher/ ) 和 Swipejs ( http://swipejs.com/ )。我能够让这两个独立工作,但是当我将 swipejs 代码放在其中一个内容面板中时,代码会中断。我假设必须与 jQuery 发生冲突,但我对 jQuery 还很陌生,我一直坚持如何调试问题。以下是我当前的代码。谢谢你的帮助。
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/jquery.content-panel-switcher.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
jcps.fader(300, '#switcher-panel', '.set1');
jcps.slider(500, '#switcher-panel2', '.set2');
});
</script>
<table>
<tr>
<td>
<div class="block mid margin_auto">
<div class="header">
<div class="nav_buttons">
<a id="set1panel1" class="switcher set1">Home</a>
<a id="set1panel2" class="switcher set1">Photography</a>
<a id="set1panel3" class="switcher set1">Design</a>
</div>
</div>
<div id="switcher-panel"></div>
<!-- Dummy Data -->
<div id="set1panel1-content" class="switcher-content set1 show">
<h2>Set 1 Panel 1</h2>
Set 1 Panel 1 content goes here.....
<div id='mySwipe' style='max-width:500px;margin:0 auto' class='swipe'>
<div class='swipe-wrap'>
<div><b>0</b></div>
<div><b>1</b></div>
<div><b>2</b></div>
<div><b>3</b></div>
<div><b>4</b></div>
<div><b>5</b></div>
</div>
</div>
<div style='text-align:center;padding-top:20px;'>
<button onclick='mySwipe.prev()'>prev</button>
<button onclick='mySwipe.next()'>next</button>
</div>
</div>
<div id="set1panel2-content" class="switcher-content set1">
<h2>Set 1 Panel 2</h2>
Set 1 Panel 2 content goes here.....
</div>
<div id="set1panel3-content" class="switcher-content set1">
<h2>Set 1 Panel 3</h2>
Set 1 Panel 3 content goes here.....
</div>
</div>
</td>
<td>
<div class="block mid margin_auto">
<div class="header">
<div class="nav_buttons">
<a id="set2panel1" class="switcher set2">Experience</a>
<a id="set2panel2" class="switcher set2">Sports</a>
<a id="set2panel3" class="switcher set2">Hobbies</a>
</div>
</div>
<div id="switcher-panel2"></div>
<!-- Dummy Data -->
<div id="set2panel1-content" class="switcher-content set2 show">
<h2>Set 2 Panel 1</h2>
Set 2 Panel 1 content goes here.....
<div id='mySwipe2' style='max-width:500px;margin:0 auto' class='swipe'>
<div class='swipe-wrap'>
<div><b>A</b></div>
<div><b>B</b></div>
<div><b>C</b></div>
<div><b>D</b></div>
<div><b>E</b></div>
</div>
</div>
<div style='text-align:center;padding-top:20px;'>
<button onclick='mySwipe.prev()'>prev</button>
<button onclick='mySwipe.next()'>next</button>
</div>
</div>
<div id="set2panel2-content" class="switcher-content set2">
<h2>Set 2 Panel 2</h2>
Set 2 Panel 2 content goes here.....
</div>
<div id="set2panel3-content" class="switcher-content set2">
<h2>Set 2 Panel 3</h2>
Set 2 Panel 3 content goes here.....
</div>
</div>
</td>
</tr>
</table>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src='js/swipe.js'></script>
<script>
// pure JS
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
startSlide: 0,
// auto: 3000,
// continuous: true,
// disableScroll: true,
// stopPropagation: true,
// callback: function(index, element) {},
// transitionEnd: function(index, element) {}
});
// with jQuery
// window.mySwipe = $('#mySwipe').Swipe().data('Swipe');
</script>
<script>
// pure JS
var elem = document.getElementById('mySwipe2');
window.mySwipe2 = Swipe(elem, {
startSlide: 0,
// auto: 3000,
// continuous: true,
// disableScroll: true,
// stopPropagation: true,
// callback: function(index, element) {},
// transitionEnd: function(index, element) {}
});
// with jQuery
// window.mySwipe = $('#mySwipe').Swipe().data('Swipe');
</script>