jquery text search

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-14 03:38:08

问题


I have HTML.

<body>
    <span>
        <font="color">
          adfadf
          23423423423
          ORDER_NUMBER:
        </font>
    </span>
    <span>M123456JK98766</span>
</body>

M123456JK98766 is 14 digit number. Need to check only 14 digit character.

I like to find a order number M123456JK98766 from HTML. How can I retrieve that? that number can be changed every time by using page refresh.

I have no option to add id against M123456JK98766.


回答1:


var orderNumber = $('span:contains("ORDER_NUMBER")').next().text();

test it here : http://jsfiddle.net/GmENT/4/




回答2:


There are JS functions such as match() and search()but you will still need to be retrieving a chunk of text from an element before you can even do that.



来源:https://stackoverflow.com/questions/5727252/jquery-text-search

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!