jquery - 选择第一个没有“display:none”的元素
<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>
我需要选择第一个没有样式 display:none
的 。用 jQuery 可以吗?
谢谢!
<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>
I need to select first <a/>
that doesn't have style display:none
. Is it possible with jQuery?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只要做
Just do
使用过滤器选择器,您将获得第一个可见的链接元素:
Using filter selectors you will get the first visible link element: