-1

I created a Flip toggle Switch with:

    <select id="flip1" data-role="flipswitch">
        <option value="true">true</option>
        <option value="false">false</option>
    </select>

my script code looks like this:

    <script>
         $( "#flip1").change(function(){
              alert("flip");
         });
    </script>

but if I change the Button, nothing happened. Maybe someone can help me. Thank you

steke
  • 257
  • 1
  • 2
  • 11

3 Answers3

-1

Try this:

with ready function

http://jsfiddle.net/z5stP/

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
     $( "#flip1").change(function(){
       alert("flip");
     });
   });  
</script>
Andy
  • 61,948
  • 13
  • 68
  • 95
Mr7-itsurdeveloper
  • 1,631
  • 2
  • 17
  • 24
  • thanks with this code it will work, i need to check how I loaded the jQuery library, thank you – steke Jun 23 '14 at 12:08
-1

Open your Browser Console (F12) to see the errors on your Page. Your code works but maybe your jQuery library could not found.

[https://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers][1]

Community
  • 1
  • 1
-1
try using below code

    <select id="flip1" data-role="flipswitch">
        <option value="true">true</option>
        <option value="false">false</option>
    </select>


<script>
$("document").ready(function()
{
     $( "#flip1").change(function(){
          alert("flip");
     });
});
</script>   

Note: Always call ur script after dom is loaded. Enclosing user script inside $(document).ready() function ensures ur script to called after dom element is loaded

Unknownman
  • 473
  • 3
  • 9