2012-04-19 36 views
1

嗨,這是我的點擊功能。它適用於Chrome瀏覽器和Firefox,但在IE9上做任何事情。jquery選擇的變化不適用於IE9?

當我點擊dropdownbox時,不要在IE9上運行點擊功能。

腳本:

$('.lstKuralTipleri option').click(function() { 

    switch ($('.lstKuralTipleri :selected').index()) { 
    case 0: 
     $('.SartliFormatDegereGore').slideDown(); 
     $('.SartliFormatTariheGore').slideUp(); 
     break; 
    case 1: 
     $('.SartliFormatTariheGore').slideDown(); 
     $('.SartliFormatDegereGore').slideUp(); 
     break; 
    } 
});​ 

.aspx的

<asp:ListBox style="padding-top:3px" runat="server" ID="lstKuralTipleri" CssClass="lstKuralTipleri" Width="805px"> 
    <asp:ListItem Text="> Kolon değerine göre" Selected="True"/> 
    <asp:ListItem Text="> Tarihe göre"/> 
</asp:ListBox> 
+1

究竟不起作用???另外,顯示你的HTML可以真正幫助我們幫助你。 – gdoron 2012-04-19 09:02:45

+0

我加了它。點擊功能做工 – Mennan 2012-04-19 09:08:39

+0

有幾件事。首先,使用「更改」而不是點擊。其次,將聽衆放在選擇框上,而不是選項上。 – 2012-04-19 09:10:13

回答

0

click事件上<option>不規範,因此在所有的瀏覽器不支持。
您應該使用onchange事件而不是onclick

可以讀取所有將q & A有this search,這是所有他們的主題...

更新代碼:

$('select.lstKuralTipleri').change(function() { 
    switch ($(this).index.index()) { 
    case 0: 
     $('.SartliFormatDegereGore').slideDown(); 
     $('.SartliFormatTariheGore').slideUp(); 
     break; 
    case 1: 
     $('.SartliFormatTariheGore').slideDown(); 
     $('.SartliFormatDegereGore').slideUp(); 
     break; 
    } 
});​ 
+0

thx它的我的錯我現在看到它 – Mennan 2012-04-19 09:20:39

+0

@Mnannan。沒問題。我用'change'事件添加了一個更新版本。如果我有呈現的HTML,我會做一個小提琴......對不起。 – gdoron 2012-04-19 09:22:05

相關問題