使用jquery更改checkbox:简单的方法即可实现更改CheckBox样式

吕的部落格唯女子与小人为难养也近之则不孙远之则怨

使用jquery更改checkbox

简单的方法即可实现更改CheckBox样式.演示

Code

jquery("input[@type='checkbox']", this).hide().each( function () {

jquery("<img>")
.src( this.checked ? opt.checked : opt.unchecked )
.click( function() {
var check = jquery(this).next()[0].checked == true;
jquery(this)
.src( check ? opt.unchecked : opt.checked )
.next()[0].checked = !check;
})
.insertBefore(this);
});

Usage

To target the functionality for a specific portion of your page/site use the native jquery selector engine in $().

$(document).ready( function () {
$().checkbox({checked: "checked.gif", unchecked: "unchecked.gif"});
});

 

For a more advanced version with label handling and styling through CSS see cssCheckbox

Rewrite of the checkbox plugin based on someone's suggestion of using CSS and labels to style checkbox selection. The original suggestion was in reference to http://www.chriserwin.com/scripts/crir/.

Label tags are used to style the various states of checkboxes. Uses CSS background images for checkbox styles, however images are not required. Style the "checkboxes" anyway you like.

See cssRadio plugin for a similar method to style radio form input.

Requires jquery 1.0.1, give or take a rev

所属分类:技术手册标签:AjaxJQuery 使用jquery更改checkbo 吕 @ 2006年11月8日12点10分 PM 编辑 使用jquery更改checkbox阅读(5107) 评论(0)

相关文章

评论

还没有评论
未开放评论

谷歌中使用jquery更改checkbox相关文章

数据加载中,请稍候……