简体   繁体   中英

Javascript Regex replace not working in IE10

The following JS works fine in FF, but doesn't replace anything in IE10:

var pattern = new RegExp('<span id=\"(.+?)\" class=\"questiontext\"><p(.*?)>(.+?)<\/p><\/span>', 'gim');
$('.questiontext_div').html(function(index, html) { return html.replace(pattern,'<span id="$1" class="questiontext"><legend>$3</legend></span>'); });

I am attempting to replace the p with a legend.

<div class="questiontext_div">
  <span id="C00B7205241531FD2BEF31301000101F0DESC" class="questiontext">
     <P style="font-weight: bold; color: #005881;">Text will go here!</P>
  </span>
</div>

this would likely be simpler:

$('span.questiontext p').replaceWith('<legend...etc>');

and work on all browsers

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