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) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -