问题
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