jQuery - if element text matches statement, change the matched text -


What are the ideas given below I am trying to achieve though I know that < Code> $ (this) is not working like this, I do not know what I'm trying to do:

  if ($ ('value') Text () || $ ('productcrease'). Text () == "£ 0.00") {$ (this) .text ('see product'); }   

HTML:

& lt; P class = "value" & gt; One £ 0.00 & lt; / P & gt; or & lt; P class = "productprice" & gt; One £ 0.00 & lt; / P & gt;

I like it if the text of the element matches £ 0.00, then "see the product". I hope this makes sense.

You can do a function by:

  $ ('value, .productprice'). Text (work (index, text) {return! Text || text == "£ 0.00"? "See product": text;});   

When you pass in a function, jQuery will call a function once for each element, and set the text of the element that you will return. (Note that the first argument is the index, which you will not use, the second is what you want.)

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -