开发者

Jquery select element by index

开发者 https://www.devze.com 2023-01-09 10:11 出处:网络
There is my markup: <UL style=\"-moz-border-radius-bottomleft: 0; -moz-border-radius-bottomright: 0\" class=\"ui-tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all\

There is my markup:

<UL style="-moz-border-radius-bottomleft: 0; -moz-border-radius-bottomright: 0" class="ui-tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" sizcache="3" sizset="5">
  <LI class="ui-state-default ui-corner-top" jQuery1280326216622="3" sizcache="3" sizset="5">
    <A href="#tab_1" jQuery1280326216622="4"><SPAN>Page 1n</SPAN></A>
  </LI>
  <LI class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" jQuery1280326216622="5" sizcache="3" sizset="6">
    <A href="#tab_2" jQuery1280326216622="6"><SPAN>Page 2</SPAN></A>
  </LI>
  <LI class="ui-state-default ui-corner-top" jQuery1280326216622="7" sizcache="3" sizset="7">
    <A href="#tab_3" jQuery1280326216622="8"><SPAN>Page 3</SPAN></A>
  </LI>
  <LI class="ui-st开发者_如何学Cate-default ui-corner-top" jQuery1280326216622="9" sizcache="3" sizset="8">
    <A href="#tab_4" jQuery1280326216622="10"><SPAN>Page 4</SPAN></A>
  </LI>
</UL>

and the js code:

  jQuery(document).ready(function() {

        jQuery(".ui-layout-center").tabs({   show: loadIframe });

        rootLayout = jQuery('#container').layout
       ({
           applyDefaultStyles: true,
           north__spacing_open: 0
       });

        jQuery("#tabs_div").tabs();
        loadIframe();
    });
function reciveDataFromPages(tabIndex, data) {
       //do some thing
}

how i can active the tab with the index: tabIndex and url : data

Any ideas???


Use :eq(), eg:

$(".ui-tabs a").removeClass("active");
$(".ui-tabs a:eq("+tabIndex+")").addClass("active");

http://api.jquery.com/eq-selector/


If you want to make a tab selected based upon the tab index returned in the function receiveDataFromPages, why can't you just do this:

$(".ui-layout-center").tabs("option", "selected", tabIndex);

I'm not sure why the URL matters in the determination of the selected tab. I may not fully understand the question, though.

Hope this helps!


Use :nth-child(youIndex) in your selector.

0

精彩评论

暂无评论...
验证码 换一张
取 消