[jQuery] Patch to checkbox replacement
This update allows the use of the semantically correct "for" attribute instead of forcing the label to be immediately after the checkbox. It also requires that the checkbox be hidden via CSS, rather than via the plugin.
<span style="font-family: courier new,monospace;"> /* Images as Checkboxes */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery.fn.cssCheckbox = function () {
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery("label[@for]", this)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
.each( function(){</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( jQuery("#" + jQuery(this).attr("for"))[0].checked )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery(this).addClass("checked");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> })</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> .hover( </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> function() { jQuery(this).addClass("over"); },</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
function() { jQuery(this).removeClass("over"); }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> .click( function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> checkbox = jQuery("#" + jQuery(this).attr("for"))
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery(this).toggleClass("checked")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> checkbox.click();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> })</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br clear="all">
--
Yehuda Katz
Web Developer | Wycats Designs
(ph) 718.877.1325
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/