javascript - Does an element with a specific innerHTML exist? -
I have a list of span amets with prices:
How can I see that there is a period with example "Example 4" for example?
I have made the following efforts so far with the following result:
if ($ ('span'). TextContent = value) {console.log ('exists '); } If ($ ('span'). Html (value) {} if ($ ('span'). Html (value) .length & gt; {} <} but They always return true ..
Thanks for reading :)
A selector Is:
if ($ ('span: contains ("example4")). Length> 0) {...} However If this "Example 40" , then you can use the trick with the .filter method for the strict comparison of the approach: if ($ ('span'). Filter (function () {return $ .trim ($ .text (this)) === 'example4';}). Length & gt; 0) {...}
Comments
Post a Comment