同时将css样式添加到特定元素和链接

时间:2018-03-21 10:26:54

标签: jquery html css ruby-on-rails

我有两个css类,如下所示。

.disabled {
    font-color: #ccc;
  }

  .grayout {
    opacity: 0.6;
    filter: alpha(opacity=60);
  }

我在下面的jquery代码中使用了它们。

 $('#priority_choices li:first-child .move_up').addClass("disabled grayout");

这是应用css样式后显示链接的方式 This is how the link displayed after applying the css styles

我需要应用其他一些样式来改变颜色。但是,当我应用font-color : #ddd;时,只会更改颜色或箭头。 我检查代码,样式在公共文件中应用于下面的单词。所以这种风格适用于所有a.iconic_link应用范围。

a.iconic_link span {
    color: #003399;
    text-decoration: underline;
    margin-left: 2px;
}

如何仅为该元素更改颜色#003399。

被修改

这是与ruby on rails一起使用的html代码。

<%= form_tag respond_round_path(round), :remote => true do %>
    <ul id="priority_choices">
      <% round.item_version.metadata["responses"].each_with_index do |r, i| %>
          <li id="choice_<%= i %>">
            <div class="movers">
              <%= iconic_link_to_function "arrow-up", "Up", "moveUp(#{i})", :class => "move_up", :data_label_up => "Option " +r.gsub('<p>', '').gsub('</p>', '').html_safe + " Move Up Selected", :option_label_up => r.gsub('<p>', '').gsub('</p>', '').html_safe %>
              <%= iconic_link_to_function "arrow-down", "Down", "moveDown(#{i})", :class => "move_down", :data_label_down => "Option "+ r.gsub('<p>', '').gsub('</p>', '').html_safe + " Move Down Selected", :option_label_down => r.gsub('<p>', '').gsub('</p>', '').html_safe %>
            </div>
            <%= r.gsub('<li>', '').gsub('</li>', '<br />').html_safe %>
          </li>
      <% end %>
    </ul>
    <%= submit_tag "Submit response" %>
    <%= hidden_field_tag "response" %>
<% end %>

我在下面的函数中应用了css。

function updateButtons() {

        $('#priority_choices li:first-child .move_up').addClass("disabled grayout");

    }

由于

1 个答案:

答案 0 :(得分:0)

变化

.disabled {
    font-color: #ccc;
  }

.disabled {
    color: #ccc;
}
相关问题