Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
issue with the code not working in internet explorer

I am using one code which is working in all browsers but not in IE11 or IE10

how can i fix it

$(`#${formID} textarea:not(.ctype)`).each(function(k) {

because it seems the usage of the ` is problematic and IE does not like it

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to mock template literals in IE, the closest thing you can do is format a string and replace placeholder values with an entry map.

// Custom formatter function
function frmt(str, obj) {
  return Object.entries(obj).reduce(function(acc, [key, val]) {
    return acc.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), val);
  }, str);
}

// jQuery selector
const selector = frmt('#${formID} textarea:not(.ctype)', { formID: 'my-form' });

console.log(selector);

$(selector).each(function(textarea) {
  console.log($(this).text());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="my-form">
  <textarea>A</textarea>
  <textarea>B</textarea>
  <textarea class="ctype">C</textarea>
</form>


If you want to make the code portable, you can write a jQuery plugin:

// Custom selector plugin
(function($) {
  $.sel = function(selector, repl) {
    return $(Object.entries(repl).reduce(function(acc, [key, val]) {
      return acc.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), val);
    }, selector));
  };
})(jQuery);


$.sel('#${formID} textarea:not(.ctype)', { formID: 'my-form' })
  .each(function(textarea) {
    console.log($(this).text());
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="my-form">
  <textarea>A</textarea>
  <textarea>B</textarea>
  <textarea class="ctype">C</textarea>
</form>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!