I need that the FOR cycle stops working if IF condition gave False. In this case, the Each cycle worked on for the elements
$ ('. Item'). Each (function () {
var NextItems = $ (this) .Parent (). NextALL () // Take all the elements that after the parent
$ (this) .Parent (). After ('& lt; div class = "ingredient-item-wrap" & gt;') // Create div and insert after your parent
var newwrap = $ (this) .Parent (). Next (). First (); // Select the created above
For (var i = 0; I & lt; nexTiTems.Length; i ++) {// Cycle for all elements that are after the parent
If ($ (NextItems [i]). Find ('. Item'). length == 0) {// If the element does not have inside the sofa with the class, then we perform the script below
if ($ (NextItems [i]). Hasclass ('WC-PAO-Addon-Container')) {// If the next item has a class, then we perform the script below
newwrap.append ($ (NEXTITEMS [I])); // insert this block into the wrapper
}
} else {// if the element inside has a WC-PAO-Addon-Heading class, then go below
RETURN FALSE // stops both cycles, must stop this for
}
}
})
The script works correctly, only for the first .item
, turns on.
Please tell me
Answer 1
if (nextitems [i]). Find ('. Item'). length == 0) {
...
} else {
Break;
}