jQuery,字符串,查找 [英] jquery, string, find
问题描述
HI,
有人可以帮我吗?
这是我的HTML:
<div class="Breadcrumb">
<a href="#">Home</a> >
<a href="#">Projects</a> >
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();
但是我不需要这个" >
"
but I don't need this one " >
"
谢谢!
推荐答案
这是不可能的,因为 > Projects Text
实际上是DOM树中的一个节点.因此,您不能单独滤除Projects Text
.如果您知道该文本以 >
开头,则可以将其分开.
That's not possible, as > 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 >
, you could however simply split that out.
或者按照MillsJROSS的建议,您需要将代码放入另一个标签中.
Or as MillsJROSS suggested, you need to put the code inside another tag.
这篇关于jQuery,字符串,查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!