html - Line through price 1 if price 5 is set javascript -
If I have the sale price (P5) then try to get the strike / line through the old price (P1)
I think I am very close, perhaps with some other part, which is stopping it by putting the line through the old price if the sale is not worth it.
& lt; Script type = "text / javascript" & gt; If (jq ('. Spn_P5')) {jq ('. Spn_P1'). Rap ("& lt; strikey & gt;"); } Else {if (jq ('. Spn_P5: empty')) {jq ('spn_P1'). Opening ("& lt; Strike";); }} & Lt; / Script & gt;
As you can see, it is still implementing the line in the second and third products.
Does anyone help please.
Many thanks.
You must check the returned length by jq (".spn_P5: blank") < / Code>, this selector returns an item return even if there is no content in .spn_P5 span. If the object has length & gt; 0 This means that an item with : blank was found
There is something similar with its HTML structure:
& lt; Div class = "boot" & gt; & Lt; Span class = 'spn_P1' & gt; 100Ã ?? ¬ & lt; / Span & gt; & Lt; Span class = 'spn_P2' & gt; & Lt; / Span & gt; & Lt; Span class = 'spn_P3' & gt; & Lt; / Span & gt; & Lt; Span class = 'spn_P4' & gt; & Lt; / Span & gt; & Lt; Span class = 'spn_P5' & gt; 200Ã? ¬ & lt; / Span & gt; & Lt; / Div & gt; You can do this:
if ($ (this) .find (".spn_P5: empty"). Length == 0) { // --- --- check length here $ (this) .find ('.spn_P1'). CSS ("text-decoration", "line-through"); } And {$ (this) .find ('.spn_P1'). CSS ("text-decoration", "")} FIDDLE
Comments
Post a Comment