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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -