jquery - Javascript function onClick doesnt recognize the object -
"basic" js understanding question;-) have js-function inside code:
<script type="text/javascript"> $(function () { $('.shoppinglist-item-add').shoppinglistitemadd(); }); </script>
the function "shoppinglistitemadd" builds dynamicly code that:
<div class="shoppinglist-item-add" id="xxx" data-setup="{'productid': '456', 'type': 'product', 'large': 'false', 'customproductname': ''}"> .... </div>
now try build function on other js file like:
$(document.body).on('click', '.shoppinglist-item-add', function(ev) { alert("sali"); })
unfortunately second function doesn't work @ all. seems, doesn't recognize dynamic build html-content first function.
i'm not js crack, can give me tip solve problem?
thanks in advance.
$(document).ready(function(){ $("div.shoppinglist-item-add").bind("click", function(){ var datasetup = $(this).attr("data-setup"); alert(datasetup); }); });
Comments
Post a Comment