开发者社区> 问答> 正文

为什么 jQuery的html()方法不能获取tr标签?

html部分:

<div id="mo">
       <tr>
        <td><input type="text" class="name"></td>
        <td><select>
            <option>顶部分类</option>
            </select>
        </td>
        <td><input type="text" class="instr"></td>
        <td><input type="text" class="order"></td>
        <td><input type="button" value="修改" class="edit"></td>
      </tr>
</div>

jQuery部分:

var str=$("#mo").html();
console.log(str);
console.log的结果:

![screenshot](https://oss-cn-
hangzhou.aliyuncs.com/yqfiles/84c1807f4c9e63f4492a933572e3f8104642cfd9.png)
为什么不能获取tr标签,怎样才能获取?

而且很奇怪的,我用after()方法的里,拼接

展开
收起
小旋风柴进 2016-06-01 08:41:47 2991 0
1 条回答
写回答
取消 提交回答
  • <div id="mo">
    
        <td><input type="text" class="name"></td>
        <td><select>
            <option>顶部分类</option>
            </select>
        </td>
        <td><input type="text" class="instr"></td>
        <td><input type="text" class="order"></td>
        <td><input type="button" value="修改" class="edit"></td>
    </div>

    以上是你给的html代码 之中 并没有

    我个人认为 .after()在这里不适用 如果要套在td外层 达到这样的效果

    <div>
    
    <tr>
        <td>
        </td>
    </tr>
    </div>

    应该使用wrapAll()方法

    2019-07-17 19:22:37
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《零基础HTML入门教程》 立即下载
天猫 HTML5 互动技术实践 立即下载
天猫HTML5互动技术实践 立即下载