<td class="profile">
<% var usedColors = ViewData["usedColors"] as string[]; %>
<a class="profile-color" href="#" style="background: #c00; <% if (usedColors.Contains("#c00") && Model.Color != "#c00") {%>display:none<% }%>" id="color-c00">Color1</a>
<a class="profile-color" href="#" style="background: #3491c2; <% if (usedColors.Contains("#3491c2") && Model.Color != "#3491c2") {%>display:none<% }%>" id="color-3491c2">Color2</a>
<a class="profile-color" href="#" style="background: #ca5c00; <% if (usedColors.Contains("#ca5c00") && Model.Color != "#ca5c00") {%>display:none<% }%>" id="color-ca5c00">Color3</a>
<a class="profile-color" href="#" style="background: #6c0; <% if (usedColors.Contains("#6c0") && Model.Color != "#6c0") {%>display:none<% }%>" id="color-6c0">Color4</a>
<a class="profile-color" href="#" style="background: #5a35a4; <% if (usedColors.Contains("#5a35a4") && Model.Color != "#5a35a4") {%>display:none<% }%>" id="color-5a35a4">Color5</a>
<a class="profile-color" href="#" style="background: #e4bc00; <% if (usedColors.Contains("#e4bc00") && Model.Color != "#e4bc00") {%>display:none<% }%>" id="color-e4bc00">Color6</a>
<a class="profile-color" href="#" style="background: #00b8a5; <% if (usedColors.Contains("#00b8a5") && Model.Color != "#00b8a5") {%>display:none<% }%>" id="color-00b8a5">Color7</a>
<a class="profile-color" href="#" style="background: #9e9a89; <% if (usedColors.Contains("#9e9a89") && Model.Color != "#9e9a89") {%>display:none<% }%>" id="color-9e9a89">Color8</a>
<a class="profile-color" href="#" style="background: #de4fec; <% if (usedColors.Contains("#de4fec") && Model.Color != "#de4fec") {%>display:none<% }%>" id="color-de4fec">Color9</a>
<a class="profile-color" href="#" style="background: #6b502e; <% if (usedColors.Contains("#6b502e") && Model.Color != "#6b502e") {%>display:none<% }%>" id="color-6b502e">Color10</a>
<a class="profile-color" href="#" style="background: #1e4aa6; <% if (usedColors.Contains("#1e4aa6") && Model.Color != "#1e4aa6") {%>display:none<% }%>" id="color-1e4aa6">Color11</a>
<a class="profile-color" href="#" style="background: #000; <% if (usedColors.Contains("#000") && Model.Color != "#000") {%>display:none<% }%>" id="color-000">Color12</a>
</td>
我需要选择没有样式<a/>
的第一个display:none
。用jQuery可以吗?
谢谢!
答案 0 :(得分:9)
只做
$('a:visible:first')
答案 1 :(得分:1)
使用过滤器选择器,您将获得第一个可见的链接元素:
$('a:visible:first')
答案 2 :(得分:0)
$('a').filter(':visible').filter(':first')