单击时将按钮设置为活动
Set button to active on click?
我试图在单击按钮时更改按钮的颜色,但它不起作用。.radio_button:hover
函数有效,但.radio_button:active
函数无效。(我认为CSS被引导CSS覆盖了,可能是这样吗(如果是这样,我如何覆盖引导CSS)?
带按钮的表单:
<table border="0" width="100%" cellpadding="5px">
<tr>
<td>
<%= simple_form_for(@post, :html => {:class => 'form-inline' }) do |f| %>
<%= f.input :link, label: false %>
<%= f.input :tag_list, placeholder: "Add some tags...", label: false %>
<div id="type_group" class="btn-group" data-toggle="buttons-radio">
<%= f.input :type, as: :hidden %>
<a class="radio_button" id="radio_button_zero" data-value="0">ZERO</a>
<a class="radio_button" id="radio_button_one" data-value="1">ONE</a>
<a class="radio_button" id="radio_button_two" data-value="2">TWO</a>
</div>
<%= button_tag(type: 'submit', class: "submit_button") do %>
POST!
<% end %>
<% end %>
</td>
</tr>
</table>
CSS:
.radio_button {
color: white;
background-color:#828282;
font-family: 'Fjalla One', serif;
font-size: 10pt;
font-weight: 100;
text-align: center;
font-style: italic;
padding:0px 6px;
padding-right: 8px;
padding-top: 3px;
padding-bottom: 2px;
text-decoration:none;
border: none;
}.radio_button:hover {
background-color:#0E9EBB;
color: white;
text-decoration:none;
}.radio_button:active {
position:relative;
background-color:#0E9EBB;
top:1px;
}.radio_button,.btn:focus{
outline:none!important
}
咖啡脚本:
$ ->
$("a.radio_button").click (e) ->
e.preventDefault();
clickedValue = $(this).data("value")
$("#post_type").val clickedValue
if clickedValue == 0
$("#radio_button_zero").addClass('active')
查看的所有更改
http://demo.sumedhasoftech.com/manoj/test/test.html
如果你想覆盖引导css,只需在引导之前包含你的css。。。或者你可以使用jQuery。。。
<style>
.active {
position:relative;
background-color:#0E9EBB; /* u can use background-color:#0E9EBB!important;*/
top:1px;
</style>
$('button').click(function (){
$(this).addClass('active');
});
相关文章:
- 是否可以在调用时动态设置Jquery Accordion的活动面板
- 使用 AngularJS 设置活动选项卡样式
- 如何在选择子li时将父li类设置为活动
- JQuery UI 1.11 将选项卡设置为活动状态
- 在页面加载时创建/设置活动的默认链接,但在单击其他链接时删除活动链接
- 如何将类设置为活动
- Bootstrap/AngularJs:如何为导航类的活动选择设置粗体属性
- 在owlCarousel中设置活动项目
- 设置活动链接(不带 ul 列表)
- 无法设置活动菜单元素的样式
- 将焦点设置在带有错误消息的第一个输入元素上,并将包含它的 TabStrip 选项卡设置为活动状态
- 将导航选项卡样式类设置为活动,如果当前在该路由中 反应反应路由器.
- 如何为引导轮播设置活动幻灯片
- 同时为一个 Li 元素设置类“活动”
- 在手风琴中设置活动部分
- 将当前链接设置为活动
- 设置活动选项卡当前选项卡
- 基于url设置活动选项卡
- 在静态导航上动态设置活动链接
- 将类活动设置为下一个幻灯片元素