Jquery text() compare to title in IE7

风流意气都作罢 提交于 2019-12-12 20:35:05

问题


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:


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()


来源:https://stackoverflow.com/questions/7183480/jquery-text-compare-to-title-in-ie7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!