Jquery text search

jqueryregexsearchtext

i have html .

<body>

<span><font="color">
adfadf

23423423423

ORDER_NUMBER: </font></span><span>M123456JK98766</span>

</body>

i like to find a order number M123456JK98766 from html.
how can i retreive that? that number can be changed every time by using page refresh.

I have no option to add id against M123456JK98766.

Best Solution

var matches = $('body').text().match(/ORDER_NUMBER:\s?([A-Z\d]+)/);

if (matches[1]) {
    console.log(matches[1]); // 22M123456JK98766
}

jsFiddle.

Related Question