Yasin
Yasin

Reputation: 181

jQtouch toggal checkbox change default position to On

I am using jQtouch for my iPhone application,

I need to check box filed, in jQtouch we have the code below like this.

<ul>
    <li> 
      Toggle The <span class="toggle"><input type="checkbox"/></span>
    </li>
</ul>

By using this code we can display the On-Off image, in the it will be by default off position.

But I need the 'On' position by default.

can you some one help me out for this.

Upvotes: 1

Views: 900

Answers (1)

Nick Wallbridge
Nick Wallbridge

Reputation: 196

The simplest solution is to add "checked" to the <input> tag:

Toggle The <span class="toggle"><input type="checkbox" checked/></span>

IF you want to handle programmaticaly:

$('toggle input[type="checkbox"]').attr('checked', true)

If you put that in your .Ready() (or page loaded function) the checkbox will be checked by default.

I would recommend that you give the Checkbox an id so that you can specify exactly which you want to change:

<ul>
    <li> 
      Toggle The <span class="toggle"><input id="myCheckbox" type="checkbox"/></span>
    </li>
</ul>

Then use:

$('#myCheckbox').attr('checked', true)

Upvotes: 3

Related Questions