gpt4 book ai didi

php - jQuery 手机 : Two/three column vertical control group of radio buttons

转载 作者:行者123 更新时间:2023-11-28 06:19:19 25 4
gpt4 key购买 nike

我最近一直在使用 jQuery Mobile,并且开始遇到各种限制;其中大部分我可以使用某种 jQuery/Javascript/CSS 操作来解决。我们使用了很多 iPad,它比普通手机更宽。我们页面上的一些输入组往往以两列格式看起来更好;可能的话。

一个例子是一长串单选按钮。仅在一列中看起来很糟糕。我们希望以 2 或 3 列显示单选按钮列表,而不是使用单个“垂直”“控制组”获得的典型 1 列格式。请参阅此演示页面上的垂直控制组:

http://demos.jquerymobile.com/1.4.5/checkboxradio-radio/#Verticalgroup

对于复选框,我通过创建两个或三个不同的控制组然后将它们放入一个 3 列网格中来完成此操作。这适用于复选框,但我不确定如何使用单选按钮执行此操作。有什么想法吗?

我假设我可以创建三个不同的 radio 输入垂直控制组(并排),然后操纵 CSS 使它看起来像一个组。我必须为实际选择的 radio 管理一个隐藏的输入。

最佳答案

我决定为营销来源创建两列;右边和左边。名称是“marketing_source_left”和“marketing_source_right”。我填充了两个 radio 垂直控制组,然后使用 jQuery 将两者更改为仅具有“marketing_source”的“name”属性。

// Define current marketing_source value and remove hidden field
var marketing_source = $('#marketing_form #marketing_source').val(); // hidden field
$('#marketing_form #marketing_source').val(marketing_source).remove();

// Change all marketing source radios (left and right sides)
// to have property name="marketing_source"
$("#marketing_form input:radio[name='marketing_source_left']").prop('name', 'marketing_source').prop('checked', false);
$("#marketing_form input:radio[name='marketing_source_right']").prop('name', 'marketing_source').prop('checked', false);

// Set the radio to checked for the marketing source value
$('#marketing_form input[type="radio"]:checked').prop('checked', false); // Uncheck current
$('#marketing_form input:radio[name="marketing_source"]').filter('[value="'+marketing_source+'"]').prop('checked', true);
$('#marketing_form input:radio[name="marketing_source"]').checkboxradio('refresh');

使用的 CSS 与此类似。

#marketing_right_div, #marketing_left_div {
display: inline-block !important;
width: 314px !important;
text-align: top;
vertical-align: top;
}

关于php - jQuery 手机 : Two/three column vertical control group of radio buttons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35706871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com