简体   繁体   English

jQuery hasClass()在IE 11中不起作用,但在Chrome和Firefox中起作用

[英]jQuery hasClass() not working in IE 11 , but works in Chrome and Firefox

I have the below piece of code which works perfectly in Chrome and Firefox , but in IE 10 and 11 , it is not working. 我有以下一段代码,它们在Chrome和Firefox中完美运行,但是在IE 10和11中,它无法正常工作。

Also when I open the Developer Tools in IE ,it works correctly. 另外,当我在IE中打开开发人员工具时,它也可以正常工作。

Can anyone help out? 有人可以帮忙吗?

$("body" ).on( "click", ".js-save-request-meta", function(event) {
    event.preventDefault();
    var el = $(this);
    var meta_value = el.data('meta-value') || $('input[name="meta_value"]').val();
     if(el.hasClass('aspect-is-selected')){
        $.post( "../ajax/delete_Request_Meta.php", {meta_value:meta_value,request_id:RequestData.request_id} )
        .done(function( data ) {
            showMessage( data );                       
         });

    }else{

        $.post( "../ajax/save_Request_Meta.php", {meta_value:meta_value,request_id:<?=$request['request_id']?> } )

         .done(function( data ) {
            showMessage( data );              
                }      
           });     
});

try adding missing function 尝试添加缺少的功能

var isFunc = $.isFunction($.fn.lettering);

if (!isFunc){
  jQuery.fn.yourfunctionname = function() {
    return new RegExp(' ' + className + ' ').test(' ' + this[0].className + ' ');
  };
}

This issue is caused due to caching problem. 此问题是由于缓存问题引起的。 This can be rectified by changing the settings in the browser to clear cache and refresh from server. 可以通过更改浏览器中的设置以清除缓存并从服务器刷新来纠正此问题。 But IE 11 still has issue with the refreshing of cache. 但是IE 11在刷新缓存方面仍然存在问题。

But the code works fine in IE 10. Thanks! 但是该代码在IE 10中可以正常工作。谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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