jquery更改选择复选框 [英] jquery change select to checkbox

查看:102
本文介绍了jquery更改选择复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单中,我想通过点击一个链接来改变选择到与之前选择相同选项的复选框列表。
我已经用show / hidden div做过,但是隐藏部分的选择仍然活跃并且与结果混淆。
所以我不知道如何处理这个问题,这就是我寻求帮助的原因。

in my form, I would like to change, with one click on a link, a select to a list of checkbox with the same choice that the previous select. I already did with a show/hidden div but the matter is the selection of the hide part is still active and mess up with the results. So I don't know how to handle this and that's why I ask for your help.

谢谢

推荐答案

您可以禁用元素选择,或者您可以删除其名称属性。以下是一个示例代码段:

You can disabled element select or you could remove its name attribute. Here is a sample snippet:

$('#mylink').click(function(e){
    e.preventDefault();
    $('#myselect').prop('disabled','disabled').hide();
    $('#myselect option').each(function(){
         $('#mylist').append('<input type="checkbox" value="'+$(this).val()+'">'+$(this).val()+'</input>');
    });
});

这篇关于jquery更改选择复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆