Reputation:
I am trying to append some html in a div i.e.
$("#color").append('<label>Color</label><select id="sel"><option>Natural</option><option>Black</option><option>White</option><option>Navy</option></select></br><label>Quantity</label> </span><input type="text" name="qty"></br><label>Unit Price</label><div class="input-prepend"> <span class="add-on">$</span><input type="text" name="uprice"><span class="add-on">.00</span></div></br>**<a href="#" id="item-add" class="btn btn-info">Add Item</a>**');
and then trying to call that button Click function i.e.
$('#item-add').on('click','.(function(){
alert("HELLO");
});
But it doesn't seems to be working. Please help. Thanks
Upvotes: 0
Views: 1262
Reputation: 195
Try your click event like this
$('#item-add').on('click',(function(){
alert("HELLO");
});
Upvotes: 0
Reputation: 3635
Replace your event handler like this:
$(document).on('click', '#item-add', function() {
alert("HELLO");
});
Upvotes: 2
Reputation: 828
Look syntax error, could you try that;
$('#item-add').on('click',function(){
alert("HELLO");
});
Upvotes: 1