Jquery text() compare to title in IE7

2019-07-23 18:45发布

In response to my last question here:

Jquery to detect identical class and text for tab navi

I have a got it succesfully working in all browsers except IE 7. IE 8,9 FF 5,6 Safari and Chrome all can implement my code correctly except ie7.

Anyone suggestions?

Fiddle http://jsfiddle.net/arkjoseph/3FrDY/

1条回答
虎瘦雄心在
2楼-- · 2019-07-23 19:39

DEMO

$("ul.nav li").click(function() {
    var i = $(this).index();
    $(".slideMove .slide").fadeOut("slow");
    $('.slideMove .slide:eq('+i+')').fadeIn('slow');
});

I think you are complicating something that can be very simple.

If you have (for example) three navigations:

li
li
li

and the three tabs:

tab
tab
tab

The easiest way is to grab the index number of the 'action button li' that will trigger the 'tab' with SAME index using the jQuery's :eq() selector.

  • Doing so - you prevent code brakes due to (always possible) editor typo.


jQuery API Docs:
:eq()
.index()

查看更多
登录 后发表回答