2012-10-17 93 views
0

設定CSS與jQuery的​​這裏是jQuery代碼:不能在IE

$('.top:last-child').css({'color':'red'}); 

爲了證明選擇的作品我想:

$('.top:last-child').hide(); 

而且這是工作。

下面是HTML代碼

<table class="topMenu" cellpadding="0" cellspacing="0"><tr><td class="top" id="tm_active" > 
    <a href="http://www.********/member.php" class="top_link"><span class="down" style="font-weight:normal;">Startpagina</span> 
    <!--[if gte IE 7]><!--></a><!--<![endif]--> 
    <div style="position:relative;display:block;"></div> 
</td><td class="top" > 
    <a href="http://www.******/" class="top_link"><span class="down" style="font-weight:normal;">Mijn Profiel</span> 
    <!--[if gte IE 7]><!--></a><!--<![endif]--> 
    <div style="position:relative;display:block;"></div> 
</td><td class="top" > 
    <a href="http://www.******/search.php?show=match" class="top_link"><span class="down" >Matches</span> 
    <!--[if gte IE 7]><!--></a><!--<![endif]--> 
    <div style="position:relative;display:block;"></div> 
</td><td class="top" > 
    <a href="http://www.*******/mail.php?mode=inbox" class="top_link"><span class="down" style="font-weight:normal;">Berichten</span> 
    <!--[if gte IE 7]><!--></a><!--<![endif]--> 
    <div style="position:relative;display:block;"></div> 
</td><td class="top" > 
    <a href="http://www.**********//" class="top_link"><span class="down" >`</span> 
    <!--[if gte IE 7]><!--></a><!--<![endif]--> 
    <div style="position:relative;display:block;"> <!--[if lte IE 6]><table id="mmm"><tr><td><![endif]--> 

    <!--[if lte IE 6]></td></tr></table></a><![endif]--></div> 
</td></tr></table> 

它完美了Firefox和Opera。 問題:仍然存在,但解決了一個解決辦法

+0

顯示你的整個HTML表格標記。這可能是你有無效的HTML。 – Curt

+0

儘管它都是正確的,但我會做任何方式 –

+0

css'顏色:紅色'適用於文本,你有最後的'​​'?中的任何文本內容? – Neverever

回答

1

對於這個問題,你在CSS代碼中使用和不使用jQuery

.top:last-child{ 
    color:red; 
} 

問候

+0

坦率地說,你的答案應該是我的合乎邏輯的選擇,它是。它完美地工作。謝謝你的提示,我想,但我會離開問題打開因爲我真的想知道最新的問題...再次感謝 –

+0

我可以看到你的CSS代碼,我想你的CSS代碼是錯誤的,jquery不工作 –

+0

沒有我的意思謝謝它的工作答案.. :) –

1

所有版本的ie不支持「:last-child」 - 選擇器。嘗試使用「去年()」方法,而不是:

$('.top').last().css({'color':'red'}); 
+1

實際上它的確如此,我試過你的建議,它沒有工作..謝謝你的答案:) –

+0

我可以看到你的css代碼,我猜你的css代碼是錯誤的,jquery不工作 –