javascript - Jquery tranversing DOM to find consecutives values -
Thanks for watching, all helpful answers have been voted. This is my markup. I am constantly trying to merge with two divs cmk1 and cmk2 content right and here in consecutive order.
- Should not match
div id 1because one iscorrectbutnot here. - should not match
div id 3because there is aherebut there is nocorrect - I'm trying to find something that looks like
div id2ascorrectashere. In addition, the text should be accurate:& lt; Div & gt; More accurate than & lt; / Div & gt;, even if the wordright
is the most effective way to do this?
Update: I was just an idea, me every class = cmk1 . If it matches correctly, then I can select its Next (Semic2) and if that also matches, I want it. But how can I do this while loop in jquery? And most importantly, how do I get out of it?
& lt; Div class = "sep" id = "1" & gt; & Lt; Div class = "cmk1" & gt; True & lt; / Div & gt; & Lt; Div class = "cmk2" & gt; Well & lt; / Div & gt; & Lt; Div class = "opp" & gt; Wald & lt; / Div & gt; & Lt; One square = "go" & gt; Go & lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "clear" & gt; & Lt; Div class = "sep" id = "12" & gt; & Lt; Div class = "cmk1" & gt; Right & lt; / Div & gt; & Lt; Div class = "cmk2" & gt; Here & lt; / Div & gt; & Lt; Div class = "opp" & gt; Gonna & lt; / Div & gt; & Lt; One square = "go" & gt; Go & lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "clear" & gt; & Lt; Div class = "sep" id = "59" & gt; & Lt; Div class = "semic1" & gt; Valle & lt; / Div & gt; & Lt; Div class = "cmk2" & gt; Wolf & lt; / Div & gt; & Lt; Div class = "opp" & gt; Here & lt; / Div & gt; & Lt; One square = "go" & gt; Go & lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "clear" & gt;
$ ('div.sep & gt; div') each Function () {if ($ (this) .text () == 'right') {if ($ (this) .next ('div'). Text () == 'HERE') {alert ('values In continuous id id: '+ $ (this) .Parent (). Attr (' id ')); Return;}}}); I have basically opened all the children in every SEP div and have tested for the first word. If this is matched, then it can be used to determine that the next word contains other words.
Comments
Post a Comment