Hi,
I have the following code structure:
- <img
id="#nextTab" src="..." />
- <div style="width:700px;overflow:hidden">
-
<div id="tabs" style="width:2000px">
- <ul>
-
<li>Tab 1</li>
-
<li>Tab 2</li>
- <li>...</li>
-
<li>Tab N</li>
- </ul>
- </div>
- </div
As the total width of the tabs is larger than the screen, the newly
selected tab should slide to the left when the "nextTab"
element is clicked.
The following code succeeds in moving the set of tabs 300px left, but
when trying to set the offset dynamically, it fails (see the last line
which was commented out). Certainly some syntax error with the quotes ...
Who can help? Thanks.
- jQuery(document).ready(function(){
-
jQuery("#nextTab").click( function() {
-
var api = jQuery("ul.tabs").data("tabs");
-
var storeLeft = api.getCurrentTab().position().left;
- api.next();
- alert(storeLeft);
- alert(api.getCurrentTab().position().left);
- jQuery("#tabs").css({'position':'relative','left':'-300px'});
-
//jQuery("#tabs").css({'position':'relative','left':'+='+storeLeft-api.getCurrentTab().position().left+'px'});
-
- });
- jQuery("ul.tabs").tabs(".pane");
-
- });
N.B. The final code should also slightly different as the storeLeft
variable should store the left position of the very first tab. Hence,
the "api" and "storeLeft" variables will probably be
moved outside the .click() function.