This is some great code - I really dig it. It's super simple, which is good.
Just as a mini-tutorial to the upcoming 1.0b, here are some of the
changes that are possible:
jQuery.fn.checkbox = function (opt) {
$("[EMAIL PROTECTED]'checkbox']", this).hide().each(function(){
$("<img>")
Notice the element creation here... very slick John!
.src( this.checked ? opt.checked : opt.unchecked )
.click( function() {
var check = this.src == opt.checked;
$(this)
.src( check ? opt.unchecked : opt.checked )
.next().attr( "checked", check ? "" : "checked" );
}).insertBefore( this );
});
};
I'm not saying that mine is any better - just using this as a
demonstration of what's possible.
--John
> 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 = "" ? opt.checked : opt.unchecked;
>
> $(img).click( function() {
>
> var input = this.nextSibling;
> if ( input.checked ) {
> this.src = "">> input.checked = "";
> }
> else {
> this.src = "" ;
> 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/
