Reputation: 375
I have a problem with click function in mobile webpage. Here is my html code
<div data-role=content>
<input type="text" id="text">
<div id="ss"></div>
</div>
<script type="javascript">
$(document).ready(function() {
$("#text").keyup(function(){
$('#ss').append('<div style="background:yellow;" >Text<br/><a class="te"> alert </a></div>');
});
$(".te").click(function(){
alert("It is working");
});
});
</script>
Please help me with solving this problem.
Upvotes: 7
Views: 18157
Reputation: 3802
'click touch' OR 'touchstart'
$('.delete-my-account').on('click touch', function(e) {
e.preventDefault();
e.stopPropagation();
if (! confirm('Are you sure?')) {
return false;
}
//...
});
Upvotes: 0
Reputation: 104775
Your element is added dynamically, use event delegation. Change your click event to:
$(document).on('click', '.te', function() {
//do stuff
});
Upvotes: 17