I Have the below code and I need to find the text which is not in the span
is there any way in jquery or Javascript where I can track to find if there is a text not in the span

Loading
I Have the below code and I need to find the text which is not in the span
is there any way in jquery or Javascript where I can track to find if there is a text not in the span

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Nov 10, 2022, 10:22 AM EST
if you always get outer text within quotes then
var texts=$("body").html(); var match=texts.match(/"(.*?)"/); alert(match[1]);Abhishek ChadhaRank #402 · 6.2K reputationPosted Nov 10, 2022, 11:45 AM EST
Hi sachin
I want to know that is there any text exists other than span nodes, i don't need the text i just want to know if it exists
Sachin SinghRank #66 · 26.2K reputationPosted Nov 10, 2022, 12:46 PM EST
Then also, if outer texts (other than span) will always be in double quote then you can check length of match>0 in above code.
Sachin SinghRank #66 · 26.2K reputationPosted Nov 12, 2022, 4:30 AM EST
Sorry, couldn't understand your question last time,
the exact regex to find if any text is there outside the span tag, should be
$(function(){ var pattern=/.*?.+?/g; var ifAnyTextOutSideSpan=pattern.test($("body").html()); console.log(ifAnyTextOutSideSpan); })I have tested it and it works fine. Please let me know if it resolves your issue.
Abhishek ChadhaRank #402 · 6.2K reputationPosted Nov 29, 2022, 6:48 AM EST
No it didn't work