How to convert .live() to .on() in WordPress
-
I have following set of JS code in my wordpress site. Currently it is working fine. But since
.live()
is deprecated from JS library, I want it to convert into.on()
.I tried various combinations but got no luck. Plz help me in getting the following code converted into
.on()
.<div id="extender"></div> <p><a href="#" class="button" id="add">Add Reward</a></p> <script type="text/javascript"> jQuery(document).ready(function( $ ){ //fadeout selected item and remove $('#remove').live('click', function(event) { event.preventDefault(); $(this).parent().fadeOut(300, function(){ $(this).empty(); return false; }); }); var rows = '<p><label for="amount"><b>Amount</b></label> <input type="number" style="width:100%" name="reward[]" value="" required /> <label for="est_date"><b>Est. Date</b></label> <input type="text" style="width:100%" class="datepicker" name="reward_est_date[]" value="" required /> <a href="#" class="button" id="remove">Remove</a></p>'; //add input $('#add').click(function() { $(rows).fadeIn("slow").appendTo('#extender'); i++; return false; }); $('.datepicker').live('click', function() { $(this).datepicker('destroy').datepicker().focus(); }); }); </script>
Thanks
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to convert .live() to .on() in WordPress’ is closed to new replies.