Oooh...nice!

<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of kawika k
Sent: Tuesday, August 15, 2006 3:45 PM
To: jQuery Discussion.
Subject: [jQuery] Simple checkbox replacement



Example
http://kawika.org/jquery/checkbox/


Code
jQuery.fn.checkbox = function (opt) {

        $("[EMAIL PROTECTED]'checkbox']", this).each( function () {

                var img = document.createElement("img");
                img.src = this.checked ? opt.checked : opt.unchecked;

                $(img).click( function() {

                        var input = this.nextSibling;
                        if ( input.checked ) {
                                this.src = opt.unchecked;
                                input.checked = "";
                        }
                        else {
                                this.src = opt.checked;
                                input.checked = "checked";
                        }
                });

                $(this).parent().prepend(img)
                $(this).hide();
        });
}


Usage
$(document).ready( function () {
        $().checkbox({checked: "accept.png", unchecked: "cancel.png"});
});


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to