I want to value an array with js based on the value of an element on the web page which is an array. How can this be done?
aa=JSON.stringify(document.querySelector("#a01").innerHTML)
console.log(aa[0])<div id="a01">[[1,2],[1,3],[1,4]]</div>I want to value an array with js based on the value of an element on the web page which is an array. How can this be done?
aa=JSON.stringify(document.querySelector("#a01").innerHTML)
console.log(aa[0])<div id="a01">[[1,2],[1,3],[1,4]]</div> 
    
    The content of the element is already string. You should parse the jsonString using JSON.parse() to make that an array:
var aa = JSON.parse(document.querySelector("#a01").innerHTML)
console.log(aa[0])<div id="a01">[[1,2],[1,3],[1,4]]</div>