Jan
31

Custom Radio Button Implement with jQurey - Part II

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4 out of 5)
Loading ... Loading ...

How to make Custom Radio Button

Now try to implement on jQuery . here I learnt how to HTML, CSS and Java Script implemnt with jQuery. I make one Demo here so you get more idea. and you want to see Click here how to make Custom Radio Button???

Java Script : Select All
$(document).ready(function(){
$("label").click(function () {
$("label").removeClass("myradio").removeClass("onactive");
$(this).addClass("myradio").css({opacity: 1});
var title = $(this).text();
$(".RdSelect").text(title);
});

$("label").mouseover(
function(){
$(this).not(".myradio").addClass("onactive");
});
$("label").mouseout(
function(){
$(this).removeClass("onactive");
});
});
HTML : Select All
<div id="myradiobox">
  <ul>
    <li><label><input id="checkbox-1"/>American Express</label></li>
    <li><label><input id="checkbox-2"/>Mastercard</label></li>
    <li><label><input  id="checkbox-3"/>Visa</label></li>
    <li><label><input  id="checkbox-4"/>Blockbuster Card</label></li>
  </ul>
<br>
<span class="RdSelect"></span>
</div>
CSS : Select All
/**
* Global CSS
* Copyright cjscreativemall.com
* Revision $ID$
*/
/* -----------------------------BASE CSS----------------------------- */
html,body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td { margin:0; padding:0; }
table { border-collapse:collapse; border-spacing:0; }
fieldset,img { border:none; }
ol,ul { list-style:none; }
caption, th { text-align:left; }
h1,h2,h3,h4,h5,h6,pre,address,caption,cite,code,em,strong,th { font-size:1em; font-style:normal; font-weight:normal; }
q:before,q:after { content:''; }
/* Set uniform base font size
---------------------------------------- */
body { font:76%/1em Arial, Helvetica, sans-serif; }
table { font-size:inherit; }
select,input,textarea { font:99% verdana, sans-serif; }
pre,code { font:115% monospace; }
body * { line-height:1.5em; }

/* lists */
#main ul { margin-bottom:18px; list-style:none outside; }
#main ol { margin-bottom:18px; list-style:decimal; margin-left:2.2em; }
#main ul.arrow,
#main ul.square,
#main ul.circle { margin-left:2em; }
#main ul.arrow	{ list-style:url(images/arrow.gif) outside; }
#main ul.square { list-style:square outside; }
#main ul.circle { list-style:disc outside; }
#main ul ul.arrow,
#main ul ul.circle,
#main ul ul.square { margin-top:4px; margin-bottom:5px; }
#main ol.smalltypes { margin-left:0; padding-left:2em; }

#main dl dl { margin:0px; padding:0px; }

/* -------------------------------------------------CUSTOM RADIO------------------------------------------------- */

#myradiobox {float:left; clear:both; margin-left:10px; background:#fff; color:#000000; width:400px; height:100px; padding:30px;}
#myradiobox li { height:20px; clear:both;}
#myradiobox label {cursor:pointer; background:url(../images/radio.png) left top no-repeat; height:20px; float:left; padding-left:20px}
#myradiobox label.onactive {background: url(../images/radio.png) left no-repeat; top:-20px }
#myradiobox .myradio {cursor:pointer; background:url(../images/radio.png) left bottom no-repeat; height:20px; float:left; padding-left:20px}
#myradiobox input {position:absolute; left:-9999px;}


5 Responses
  • Derek Feb 16 2009 @ 3:38 pm

    When I used this code everything worked fine (eventually) except I tried putting a text area box in the label. When you click in the text area to write something, the radio button clicks on correctly but the mouse cursor is taken out of the box, leaving the user unable to type. Is there a simple workaround for this?

  • admin Feb 18 2009 @ 12:24 am

    Hi Derek
    What exactly you need please explain more details.

  • Jorge Aug 13 2009 @ 6:25 am

    I am trying to use your scrip to customize radion buttons. I am having an issue that i cannot figure out. i have 2 sets of radio buttons. when using your script, i can only select one radio button as if it was only one selection set. is there a fix so that i can use different selection sets. i am willing to pay. thanks!

  • Vinidog Aug 13 2009 @ 10:58 pm

    Very nice!!!

  • Kevin Nov 19 2009 @ 10:29 am

    HACKERAMA
    #myradiobox input {position:absolute; left:-9999px;}

    This is a pretty tool when you use FF - does not work well with IE6,7,8 if your using other Jquery libs…..

  • 3 Pings

    1. 24 HTML Form Elements Customization Techniques | NetWaver Apr 17 2009 @ 5:52 am
    2. 24个漂亮的个性化HTML表单技术 | 郭杰的blog Apr 18 2009 @ 9:54 am
    3. 我想网 » Blog Archive » 24 个漂亮的个性化 HTML 表单技术 Apr 19 2009 @ 11:05 pm
    Leave a Reply

    Tag Cloud

    Categories

    Archives