Hello, I am currently trying to compare two arrays containing ID numbers. If numbers in the first array are also in the second array, I want to change the style of each of the targeted element to have a background color of red. This is what I have so far:
var x = document.getElementsByTagName("td"); var len = x.length; var arr = []; for (var i=0; i<len; i++) { arr.push(x[i].id); if (arr.includes(<?php print_r(json_encode($winners_array))[0] ?> )) { x[i].style.color = "red"; } }
At the moment, I am trying to use the includes() method to compare the two arrays. This is the area that is not working. The PHP code that is json_encoded is just a PHP array I am sharing with JavaScript.
I appreciate all help! Thanks!