Home > DeveloperSection > Forums > How to Jquery toggle switch gives null on document ready
john rob

Total Post:108

Posted on    February-01-2015 10:19 PM

 JavaScript JQuery  Jquery UI 

 1 Reply(s)
 662  View(s)
Rate this:

Hi Im using jquery ui toggleswitch toggleswitch.js

how can i get on /off value on document ready

i'm using this code on document ready

   $(document).ready(function () {



it gives null but when i use firebug console and run it gives value of on/off by running this code below.


there is not much documentation of this widget can anybody help?


Pravesh Singh

Total Post:412

Posted on    February-01-2015 10:41 PM

i think you run your code before plugin did it's job (also started at ready), first check if .ui-state-active esxist, if not run timeout and try again

function checkState() {

  if ($('.ui-state-active').lenght) {


  } else {

    setTimeout(function() {


    }, 500);





$(document).ready(function() {




<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


Don't want to miss updates? Please click the below button!

Follow MindStick