此标签的正确选择器
Proper selector for this tag?
我似乎找不到适合这个标签的jquery选择器:
HTML:
<div class="span4 span4-mod">
<div class="well well-mod">
<h4 class="DomainDescription">Iniz LAX1</h4>
<span class="btn-block">
<button></button>
</span>
<form action="pinfo.php" method="post">
<input type="hidden" value="">
<button>History</button>
</form>
Port Status<br />
<span class="portstatus porton">21</span>
<table class="table" style="margin-top: 10px;">
<tbody>
<tr>
<td><strong>Distro:</strong></td>
<td class="showdistro">Debian 7.1</td>
</tr>
<tr>
<td><strong>Online since: </strong></td>
<td class="showonline">2 Days 10:29</td>
</tr>
</tbody>
</table>
</div>
我试图搜索类"DomainDescription",然后在类"showonline"中搜索HTML,并操作后者。
我正在寻找兄弟姐妹(表)>child(tbody)>child(tr)>child(td)的关系
尽管我尽力了,但我似乎找不到合适的人选来处理这种关系。
我的起点是:
$('.DomainDescription').each(function () {
var PrintedUptime=$(this).siblings().children(".showonline").html();
alert (PrintedUptime);
});
合适的选择器应该是什么?
您可以
$('.DomainDescription').each(function () {
var PrintedUptime=$(this).closest('.well-mod').find(".showonline").html();
alert (PrintedUptime);
});
演示:Fiddle
正确的css选择器是:
.DomainDescriptor~table>tbody>tr>td>.showonline
我认为这至少是正确的。因此,您可以使用:
$('.DomainDescriptor~table>tbody>tr>td>.showonline').each(function(){
alert(this.html());
})
以达到期望的效果。这没有经过测试。
相关文章:
- JQuery:单击范围标签时切换日期选择器
- 谷歌图表:无效的列标签 |类别筛选器作为列选择器
- Rally SDK 2 标签选择器是否有必填字段?对象没有方法'getContextPath'
- 查找带有多个选择器的 prev() 标签
- 花哨的jQuery标签选择器
- Twitter Bootstrap Dropdown与标签选择器
- 此标签的正确选择器
- 检查CasperJS中是否存在标签(而不是选择器)
- 如何通过按下标签显示隐藏内容使用选择器
- jQuery选择器问题与锚标签和隐藏Div
- 用于复选框标签的Jquery选择器
- 通过选择器更改视图标签的字体
- jQuery可以使用结束标签作为选择器吗?
- onclick JQuery函数在HTML标签中设置日期选择器值为不同的日期
- 在Angular js中,不能从带有标签的日期选择器中获取选定的日期
- 通过自定义标签设置午休选择器
- jQuery标签'for'属性选择器
- 为什么jquery选择器不'不适用于新替换的标签
- Jquery选择器对添加的标签不起作用
- 当在Angular 2中使用ngFor时,有没有可能不使用组件选择器标签来包装组件内容?