I wanna preventDefault a dynamically added link that is not getting recognized by the on() method. However, the static link which was already on the page preventDefault()'s itself with the same function.
<!DOCTYPE html>
<html>
<head>
<title>
Testing Phase
</title>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#txt").focus();
$('#btn').click(function(){
var inpt = $("#txt").val();
$("#dv").append("<p class='eo'>"+inpt+"--><a href='dynamic' class=''>This is dynamic link, it won't get preventDefault() with the on() method.</a></p>");
x++;
});
$('.eo').on('click', function(e){
e.preventDefault();
});
});
</script>
</head>
<body>
<input type="text" id="txt" name="">
<input type="button" id="btn" name="" value="Add">
<div id="dv">
<a href="nowhere" class="eo">This static link works with the on() method!</a>
</div>
</body>
</html>