在< br>之间选择文字 [英] Selecting text between <br>

查看:74
本文介绍了在< br>之间选择文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在
标签之间选择文字?我正在使用下面预先格式化的代码来尝试选择这些数据:纽约,纽约10012

Is it possible to select text between
tags? I am working with the preformatted code below trying to select this data: New York, NY 10012

我玩过 $('#地址')。find('br')。eq(2).text(),但要知道必须有更好的方法。

I've played around with $('#address').find('br').eq(2).text(), but know that there must be a better way.

    <div id="address">
        Joe Dirt<br>
        PO Box 842<br>
        New York NY 10012<br>
        800-555-5555<br>
        <br>
    </div>

谢谢!

推荐答案

检索 div 的HTML并拆分 br 标记:

Retrieve the HTML for the div and split on the br tag:

$.trim($("#address").html().split("<br>")[2]);

JS小提琴: http://jsfiddle.net/KQgu5/

这篇关于在&lt; br&gt;之间选择文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆