开发者

jQuery UI button - how change style and icon checked buttons?

<script type="text/javascript">
    jQuery(document).ready(function($){
        $('.date').datepicker($.datepicker.regional['cs']);
        $(".votePollState").button({ icons: {primary:'ui-icon-closethick'},text: false });
    });
</script>

HTML code:

<input type="checkbox" class="votePollState" id="point-1"/><label for="point-1">Choice 1</label>

<input type="checkbox" class="votePollState" id="point-1"/><label for="point-1">Choice 1</label>

I need setting some icons for state of checkbox, no checked checkbox has other icon and checked checkbox has other. No if i check checkbox, this has some icon but only ch开发者_高级运维ange border color.

Something use ON/OF switch button on iPhone.

THX


You could add a .change() handler that took the .checked state of the checkbox and assigned the icon based on it, like this:

$(".votePollState").button({ 
    icons: {primary:'ui-icon-closethick'},
    text: false 
}).change(function() {
    $(this).button("option", { 
        icons: { primary: this.checked ? 'ui-icon-check' : 'ui-icon-closethick' }
    });
});

You can test it out here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜