After I replace IP address in innerHTML event listeners doesn't working.
My code:
$( "iframe" ).load(function() {
$("iframe").contents().find("b").html(function(_, html) {
return html.replace(/(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)/, '<a href="http://$1/" target="_blank">$1</a>');
});
});
part of innerHTML in iframe
<a id="go" rel="leanModal" name="test_2" href="#event">2</a> <!--this anchor loses event listener -->
<li>
<ul>
<li>
<b>MyRouter1 - 192.168.1.1</b>
</li>
<li>
<b>MyRouter2 - 192.168.1.2</b>
</li>
</ul>
</li>
How to make IP address clickable without replacing innerHTML or killing DOM elements / event listeners?