toggle switch slide to trigger a JS function

toggle switch slide to trigger a JS function

in jqm, 


this is a working toggle switch:



  1. <form name="BRAND" >
  2. <select data-role="slider" name="MODEL"  id="test">
  3. <option value="off">sedan</option>
  4. <option value="on"> sportster</option>
  5. </select> </form>



and this is a way of making the switch trigger a function




slidestop triggered at the end of an interaction with the slider. Includes drags and taps.

  1. $( ".selector" ).on( 'slidestop', function( event ) { ... });


how to connect them?


I have tried using


this 


  1. <script>
  2. $( ".selector" ).on( 'slidestop', myFunction())

  3. function myFunction()
  4. {
  5. document.write("works!");
  6. };
  7. </script>



and this



  1. $( "#testo" ).on( 'slidestop', myFunction())

  2. function myFunction()
  3. {
  4. document.write("works!");
  5. };



the former works before triggering, and the latter, where i try to connect the event to more specifically a switch with id="testo", it never works.