jQuery,字符串,查找 [英] jquery, string, find

查看:98
本文介绍了jQuery,字符串,查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

有人可以帮我吗?

这是我的HTML:

    <div class="Breadcrumb">
       <a href="#">Home</a>&nbsp;&gt;&nbsp;
       <a href="#">Projects</a>&nbsp;&gt;&nbsp;
       Projects Text
    </div>

我想用jQuery来获取锚标记中没有的字符串,在此示例中为"Projects Text"

I want to get with jQuery the string what is not in anchor tag , in this example is "Projects Text"

理论上是这样

jQuery:

var name = $("Breadcrumb (not <a>) ").text();

但是我不需要这个"&nbsp;&gt;&nbsp;"

but I don't need this one "&nbsp;&gt;&nbsp;"

谢谢!

推荐答案

这是不可能的,因为&nbsp;&gt;&nbsp; Projects Text实际上是DOM树中的一个节点.因此,您不能单独滤除Projects Text.如果您知道该文本以&nbsp;&gt;&nbsp;开头,则可以将其分开.

That's not possible, as &nbsp;&gt;&nbsp; Projects Text is actually one node within the DOM tree. So you cannot get the Projects Text alone without filtering it out. If you know, that the text is preceded by &nbsp;&gt;&nbsp;, you could however simply split that out.

或者按照MillsJROSS的建议,您需要将代码放入另一个标签中.

Or as MillsJROSS suggested, you need to put the code inside another tag.

这篇关于jQuery,字符串,查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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