Good face for Check Box in Jquery


http://john.mcclumpha.org/javascript/Creating_customスタイルドcheckboxes_with_jQuery/
http://awardwinningfjords.com/2009/06/16/iphone-style-checkboxes.html
javascript:Creating custom style checkboxs with jQuery
Published:1 years ago
デモンストレーションcom .net .BIZ .info
For those of you who beve been using my DTML Effects using Javascript code,let me appogise.I have now been overtaen by the force known as jQuery!Thanks Simon:P)If nothing else it's more comptible、widely supported with a huge development communit and a lot more versatile than just a few animated effects.Anyhow、on with the show…
I got ick of the fact that checkbox es、like several other form elemens、cannot be style using css.As a reult checkbox in various browsers always appared differently and weree off engh to to rudenice
What we will do is create some links(Now style the link as follows:/fake checkbox:unchecked(default/base)state*/ fakecheck{ font:12 px Tahoma、Arial、Helvetica、sans-serif; text-decoration:none; outline:none; background:url(./imags/checkbox.gif)no-repeat; height:16 px width:40 px; display:block; float:left; padding:1 px 0 px 0 px 20 px; カラー:(菗666666;) ) //*fake checkbox:hover state*/ .fakecheck:hover{ カラー:钻0066 FF text-decoration:undeline; ) //*fake checkbox:checked state*/ fakechecked{ background-position:left-25 px; ) You shud now have a link which the check box in it's unchecked state-note however that it doesn't work just.Before we get things work、let's create the"real"checkbox(the one that will actually be used as part of the form)-this will of course be hidden at later stage.Went wathis input have the same me me the abox.ine<input type="chectname="Firstly、let's create the code to ggame the styling on the new checkbox.$ ドル(「.fakecheck」).click(){ ($(this).has Class('fakechecked')?$this).removeClass('fakechecked'):$ return false; } } The function is aached to any items styloed with the clast“fakecheck”and togles the adding/removing of the class“fakecheced”.So now it's looking good and toggling-but what aut the hidden“recked”ine.the.the.edtchect.the.the.edit.ext.ingt.ingt.ingt.ine.ine.ingt.ingt.ingt.ingt.ingt.ingh.ingt.ingt.ingt.ingt. ドル(「.fakecheck」).click(){ ($(this).has Class('fakechecked')?$this).removeClass('fakechecked'):$ ドル(this.hash).trigger("click") return false; } } As You can see,I'm using the hash value from the ancher to reference the id the checkbox(hence the y must match)In a nutshell-that's it….however thininins doturnsourif Yourefshthe path the page with th th me me me me me me me me me me me eeeeemichchchchchcheeeeeeeeeeeeeededededededededededepepepepechchchchchchchchchcheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeease ase ase ase ables alements protem.netprochement.ortworkment.ortworkment.ortment.the follwing code will doeverything above and also check the status of all check box and match the m to the fake ones.$ //check for what is/isn't already checed and match it on the fake ones ドル("input:checkbox").each(function(){ (this.checked)$fake"+this.id).addClass(''fakechecked'):'("((菗鑛fake"+this.id).removeClass(') } //function to'check'the fake ones and their matching checkbox es ドル(「.fakecheck」).click(){ ($(this).has Class('fakechecked')?$this).removeClass('fakechecked'):$ ドル(this.hash).trigger("click") return false; } } That's it!-hopefully this will be of some use to you.:イントロデレックiPhone-style Checkbox sEver wanted flash iPhone on/oftgle switch on your webpage?Love jQuery well then I've got something special for you.iphone e-style-checkbox es implemens the iPhone toggaes s s s s for standed HTML chebox.Simplyrun the script and your site the specond wided。the undeng checkbox is not touched and backend system will never know the difference.The change is purey visual.UPDATED:Now with Prottype-based version here.
Examples
A checkbox defaulting to checked
オン
オフ
A checkbox defaulting to unchecked
Download and implement
In keeping with the jQuery philosophy、using the iphone-style-checkbox es library is very simple.Download the package、unzip it and place the javascript、imags and style thereet the the the street the stine
Onese the files are available to your site、activating the script is very:
<head>
  <script src="jquery-1.3.2.js" type="text/javascript"></script>
  <script src="jquery/iphone-style-checkboxes.js" type="text/javascript"></script>
  <link rel="stylesheet" href="path_to/style.css" type="text/css" media="screen" />
  <script type="text/javascript">
    $(document).ready(function() {
      $(':checkbox').iphoneStyle();
    });
  </script>
</head>
The initialization method tars a handful of options.
  • checkedLabel sets the text of the"on"state.Defaults to:ON
  • uncheckedLabel sets the text of the"off"state.Defaults to:OFF
  • For example:
    $(':checkbox').iphoneStyle({
      checkedLabel: 'YES',
      uncheckedLabel: 'NO'
    });
    
    A checkbox defaulting to checked
    YES
    NO.
    A checkbox defaulting to unchecked
    Conttribute
    The source is available、and forkable、on GitHub at http://github.com/tdreyno/iphone-style-checkboxes.Please direct comments、support requests、bug reporting and pure requests to there.
    Comments
    Let me know at [email protected] and I'll amend the articale as necessary.