Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

jQuery create multidimensional array from multiple elements

How can I make a multidimensional array with structure like this one for each li with class sl-item:

$imagesList = [
 [1, 123, "<img src=\"/img-src/123.jpg \" />", "/photo/img-123", "image-alt "],
 [2, 452, "<img src=\"/img-src/452.jpg \" />", "/photo/img-452", "image-alt "],
];

First should be just number of array, 1,2,3..., second part is the id of li element, third is the img with img src, fourth is the url from a with class photo-url and fifth is the img alt. My structure is the following:

<ul class="sl-img">
 <li id="123" class="sl-item">
 <a class="photo-url" href="/photo/img-123">
 <img alt="image-alt" src="/img-src/123.jpg" >
 </a>
 </li>
 <li id="452" class="sl-item">
 <a class="photo-url" href="/photo/img-452">
 <img alt="image-alt" src="/img-src/452.jpg" >
 </a>
 </li>
 .....
</ul>

Answer*

Draft saved
Draft discarded
Cancel

lang-js

AltStyle によって変換されたページ (->オリジナル) /