Posts

Showing posts with the label foreach

forEach does not access all elements in NodeList

forEach does not access all elements in NodeList Since the forEach array method can now be called on a NodeList . I was wondering why if you make changes to the content of a childNodes NodeList while looping with forEach , forEach does not detect the changes. forEach NodeList childNodes forEach forEach grid.childNodes.forEach(function(tableRow, index, nodeList) { tableRow.remove(); }); Here, i'm trying to loop through my table(grid) elements children and remove each children( tableRow ) from the table. However, forEach never completely loop over every element, always leaving out one last tableRow to be remove d.I think it has something to do with the childNodes NodeList being live, and the forEach not being able to properly follow it or something. tableRow forEach tableRow remove What’s your relevant html? What’s the selector for grid ? – David Thomas 6 mins ago ...

Loop through object within an array Laravel

Image
Loop through object within an array Laravel I'm trying to loop through an object in an array in Laravel. I made a foreach to loop through my $request->newTags what is an object and I just return the key. my goal is to access each tag_name in my request object what has an array with the multiple indexes what contain the tag_name . foreach $request->newTags tag_name request object array tag_name foreach ($request->newTags as $tag) { return $tag; } and i get my response how can I access each tag_name? 2 Answers 2 Try this foreach ($request->newTags as $tag) { return $tag.tag_name; } Do you mean $tag->tag_name ? – Yosef Jul 1 at 7:11 $tag->tag_name becuase tag.tag_name return an error ...