关闭:VAL追加ATTR无法在移动
问题描述:
更新工作:我发现从片段一个代码,类似于我的设计是这里在移动我猜是这样的:关闭:VAL追加ATTR无法在移动
_colors=$('._select_color_drop li');
for (var i = _colors.length - 1; i >= 0; i--) {
$(_colors[i]).click(function(){
var color_text = $(this).find('span').attr('_text_display');
var elemnt = $(this).closest('._select_color_drop').prev();
elemnt.find('span.color').remove();
$(this).find('span').clone().appendTo(elemnt);
var contents = $(elemnt).contents();
if (contents.length > 0) {
if (contents.get(0).nodeType == Node.TEXT_NODE) {
$(elemnt).html(color_text).append(contents.slice(1));
}
}
if($('[name=_color]').val() == undefined){
elemnt.next().append("<input type='hidden' name='_color' value='"+color_text+"'>");
}else{
$('[name=_color]').val(color_text);
}
})
};
任何想法解决这个问题? T_T
我已经解决了这个问题。谢谢:)
引导形式,选择样式选项
我有一个关于自举3表单样式问题的问题。 它有任何机会的选择可以这样的风格吗? Sample design
<section>
<div class="col-md-6 col-xs-12 text-left form-cover">
<div class="form-group">
<label for="">Your Age</label>
<select class="form-control" id="">
<option>-Please select your Age-</option>
<option>Below 18</option>
<option>19-30</option>
<option>30-40</option>
<option>40 and above</option>
</select>
</div>
<div class="form-group">
<label for="">Choose Your Color</label>
<select class="form-control" id="">
<option>-Please select colour-</option>
<option><div style="background: yellow; width: 20px; height: 20px;"></div></option>
<option><div style="background: black; width: 20px; height: 20px;"></div></option>
<option><div style="background: white; width: 20px; height: 20px;"></div></option>
<option><div style="background: purple; width: 20px; height: 20px;"></div></option>
<option><div style="background: blue; width: 20px; height: 20px;"></div></option>
<option><div style="background: grey; width: 20px; height: 20px;"></div></option>
<option><div style="background: green; width: 20px; height: 20px;"></div></option>
<option><div style="background: pink; width: 20px; height: 20px;"></div></option>
</select></div>
</div>
</section>
我把DIV中的选项,但似乎不起作用。 :(
想知道它是可以使用下拉式造型,但我担心后端无法捕捉值
谢谢
答
我看到了两个简单的方法做你想要的:!
- 尝试select2(版本BS3也存在),写自己的这种风格。使用选择2,你仍然可以从选择直接获得价值。
- 使用隐藏的选择+ bootstrap 3 dropdown component谱写简单的jQuery函数:每次用户更改下拉列表的值时,隐藏选择的值也会发生变化。
+0
我会尝试使用下拉组件:)希望后端可以捕获数据。非常感谢! – CanDiceYap
+0
@CanDiceYap,不客气。如果您为'
请分享您的代码,以便我们可以帮助您。 – Shiladitya
尝试添加一些你已经尝试过的代码。 – shishir