JQuery difference between FF and Chrome

He guys why does this code work on Chrome but not FF?

The warning below is blank in FX but gives me RGB color in Chrome

jQuery.each(menuids, function(index, value) { 
        var allclass = jQuery('#'+value).attr('class');
        if( (allclass.split('current-menu-item')).length > 1){
                var currentURL = window.location.href;
                var allhtml = jQuery('#'+value).html();
                var allhtml_arr = allhtml.split('href="');

                var allhtml_arr1 = allhtml_arr[1].split('">');

                if( allhtml_arr1[0] == currentURL ) {
                    var allclass_arr = allclass.split(value);
                    var current_colorcls = jQuery.trim(allclass_arr[1]);
                    jQuery('ul#primary-menu').addClass(current_colorcls);

                    var prop = jQuery('ul.'+current_colorcls).css('border-top');
                    var prop_arr = prop.split('solid');
                    var current_colorcode = jQuery.trim(prop_arr[1]);
                    alert(current_colorcode);
                    jQuery('.crg-theme-color').css('color',current_colorcode);
                    jQuery('.site-info').css('border-top', '3px solid '+ current_colorcode);
                }
            }
    });

      

Thank!

+3


source to share


1 answer


There seems to be a problem in FX-jQuery about shortening . The border color is still too short. You can get the color using the full name:

var prop = jQuery('ul.'+current_colorcls).css('borderTopColor');

      

Example

console.log(jQuery('ul.Atlantis').css("borderTopColor"))

      



gives me "rgb(167, 204, 61)"

PS: To get a list of all classes, you can do this in newer browsers

$(element)[0].classList

      

There is a shim for older browsers here

+4


source







All Articles