[jQuery] Simple checkbox replacement

[jQuery] Simple checkbox replacement

Oooh...nice!
<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
andy@icglink.com
615.370.1530 x737
--------------//--------->
-----Original Message-----
From: discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com]On
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) {
    $("input[@type='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
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
















































    • Topic Participants

    • andy