简体   繁体   中英

is the jQuery function “change()” working in IE?

is the jQuery function "change()" working in IE ?

I usually use it to detect changes in forms (select/unselect check boxes), and submit them automatically without having to click on submit button (which is hided).

ie

$("#views-exposed-form-Portfolio-page-1").change(function(){
        $("#views-exposed-form-Portfolio-page-1").submit();   
});

But in Ie it doesn't work. It seems I have to use "click" instead. thanks

Solution in IE:

if (navigator.appName == 'Microsoft Internet Explorer') {
    $(".option").click(function(){
        $("#loadingOverlay").css('display','block');

        if ($(this).children().is(':checked')) {
            $(this).children().attr('checked', '');
        } else {
            $(this).children().attr('checked', 'checked');
        }
        $("#views-exposed-form-Portfolio-page-1").submit();     
    }); 
}

It seems Jquery change function works in IE-7 now. 'Change' can be used with select(drop down), check box and radio buttons.

In IE, change() doesn't work.. so I used the following code:

  if ($(this).children().is(':checked')) {
        $(this).children().attr('checked', '');
    } else {
        $(this).children().attr('checked', 'checked');
    }
    $("#views-exposed-form-Portfolio-page-1").submit();     
}); 

在这里查看我的答案: IE未检测到复选框的jquery更改方法

The change event will only be fired when the element loses focus (blurs). Click once again somewhere on the page so that your checkbox/radiobutton blurs, then you'll see that it get fired. In case of checkboxes and radiobuttons you'd indeed rather like to hook on click event. It also makes sense, clicking it will (un)check the checkbox/radiobutton anyway :)

This "problem" is not specifically related to IE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM