In JQuery/JavaScript, how can I find out if a Div contains a specific string/substring in one of it's child elements? I've looked into both contains and indexOf but couldn't find any examples of my specific case where I need to commit a different action if a unique string/substring of that string is found.
Pseudo Code:
if (div contains (itself or child nodes) "this string/part of this string")
then do something
else
then do something else
You can use text() of div to get all the text of the current div and its childs,
if('#divId').text().indexOf("this string/part of this string") != -1)
{
}
else
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With