{"id":359,"date":"2018-02-21T04:44:25","date_gmt":"2018-02-21T04:44:25","guid":{"rendered":"http:\/\/info.juliusgoh.life\/?p=359"},"modified":"2018-04-24T02:47:14","modified_gmt":"2018-04-24T02:47:14","slug":"javascript-get-all-class-element-and-convert-it-into-array","status":"publish","type":"post","link":"https:\/\/info.juliusgoh.life\/?p=359","title":{"rendered":"Javascript Get All Class element and convert it into array"},"content":{"rendered":"<pre>var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));\r\n<\/pre>\n<p>Explanation:<br \/>\ndocument.querySelectorAll(&#8216;ClassName ID&#8217;) &#8211; Get All Class or id element and put into object<br \/>\nArray.prototype.slice.call &#8211; Convert Object into Array<\/p>\n<p>Looping:-<\/p>\n<pre>elems.forEach(function(html) {\r\n    ### Your Code Here ###\r\n});\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>var elems = Array.prototype.slice.call(document.querySelectorAll(&#8216;.js-switch&#8217;)); Explanation: document.querySelectorAll(&#8216;ClassName ID&#8217;) &#8211; Get All Class or id element and put into object Array.prototype.slice.call &#8211; Convert Object into Array Looping:- elems.forEach(function(html) { ### Your Code Here ### });<\/p>\n","protected":false},"author":1,"featured_media":360,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/359"}],"collection":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359"}],"version-history":[{"count":5,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions\/397"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/media\/360"}],"wp:attachment":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}