Hi is there anyway to search text in dom, as we do for SQL query LIKE?
i mean, i have.
<ul>
<li>ab</li>
<li>abrecot</li>
<li>abus</li>
<li>aby</li>
<li>abrea</li>
</ul>
i would like to search for “abre” and so return in text ASC order:
<li>abrea</li>
<li>abrecot</li>
is this possible?
definitely the query would looks like doing:
SELECT <li> FROM <ul> WHERE text LIKE 'abre%' ORDER BY text ASC; :))
As you are looking for elements whose text starts with a specified string, you can use the
filtermethod:This will only return elements which have the string “abre” at the start. The other answers using the
containsmethod will return elements with the string found anywhere within them, which does not match your pseudo-SQL query.Here’s a working example of the above.