There are plenty of ways of doing it, this is one way with onerror with an image tag.
var x = $("<div/>").html('<img src="X" onerror="alert(\'hi\');" />').text();
console.log(x);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>