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

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -