0

enter image description hereIf i use ` : its working fine in Chrome browser but not working IE, if i removed and tried using ' or " getting invalid or unexpected error, please help me on this.

jQuery('label.common-label').each(function(item){
    let obj = this;
    let color = jQuery(obj).css('background-color');
    let classList = jQuery(obj).attr('class').split(' ');
    let str = '';
    for(var i=0; i < classList.length; i++) {
        str += '.' + classList[i];
    }

    str = 'label' + str + '::before';
    let str1 = '.active-facet ' + str;

    console.log(color);
    let styleList = '<style>
    ${str}{
        border-color: ${color} !important;
    }
    ${str1}{
        background-color: ${color} !important;
    }

</style>';
    jQuery(obj).parent().append(styleList);
});
Lokesh
  • 1
  • 2
  • 1
    The first problem you have is that IE doesn't support template literals surrounded by backticks `\``. The second is that those multiline strings are not syntactically correct. – VLAZ Jul 04 '19 at 10:02
  • If you want to support ie, you have to use string concatenation for example: `let styleList = ' – Exceptional NullPointer Jul 04 '19 at 10:03
  • Thanks for response @peter : i tried using this but unexpected token error let styleList = '' – Lokesh Jul 04 '19 at 10:34
  • Thanks For your Quick response @Peter : same error in chrome, **unexpected token < ** – Lokesh Jul 04 '19 at 10:55
  • Yeah, sorry I had a typo at the last ` – Exceptional NullPointer Jul 04 '19 at 11:06
  • Thanks @peter : Working fine but in html its showing like string variable – Lokesh Jul 04 '19 at 12:51
  • If you are not using template literals, `'${str}{' +` should be `str + '{' +` – Exceptional NullPointer Jul 04 '19 at 12:54
  • Thank you very much @peter working fine as expected :) – Lokesh Jul 04 '19 at 13:36

0 Answers0