jQuery的next()在元素上彼此不相邻

我有一些可怕的代码我必须处理

...
<div class="container">
   ...
    <tr>
    <td width="100" height="50">
         <a class="swaps"><img src="http://www.blah.jpg" alt="Some Title" id="1"></a></span></td>
    </tr>
   <tr>
    <td width="100" height="50">
        <a class="swaps"><img src="http://www.blah2.jpg" alt="Another title" id="2"></a></span></td>
    </tr>
</div>

如果我使用

var thisone = $(“#container .swaps:first”)

选择第一个(ID为1)为什么我在选择时遇到问题

thisone.next()?

解决方法

HTML是真的吗?我没有看到任何带有id“容器”的元素而你正在做

 $(“#container .swaps:first”)

此外,如果它是真正的HTML,您应该稍微修复它(关闭img标记,并在< / TD>之前添加跨度的开始标记)

假设您的HTML没问题,这应该适合您的方案.

var thisone = $("#container .swaps:first");
thisone.children();

IMG不是主播的兄弟,是一个孩子.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...