javascript - jQuery .on() syntax and passing multiple arguments to function -
i have following script not work on firefox seems work on google chrome.
<script> $(document).ready(function(){ $('#btn_2').on('click', function () {addselectable(event, 7)}); $(function() { $( "#selectable" ).selectable(); }); }); </script> function addselectable (event, size) { event.preventdefault(); event.stoppropagation(); alert('hello'); var s = size; var p = $('<ol>').attr('id', 'selectable'); var count = 0 (var = s; >= 0; i--) { count = count + 1; var li = $('<li>').attr('class', 'ui-state-default').text(count); $(li).appendto(p) p.append(li); } $(p).appendto('body'); alert('i done'); //};
}
how can pass multiple arguments function 'addselectable' in on click event, there alternative way of doing work on browsers?
event should goes argument of function(event)
change
$('#btn_2').on('click', function () {addselectable(event, 7)});
to
$('#btn_2').on('click', function (event) {addselectable(event, 7)});
try though not tested me.
Comments
Post a Comment