I have divs with ids as below:
<div id="text.header" class="countDiv"></div>
<div id="text.content" class="countDiv"></div> etc
I have two arrays. In the first i have, array1 = [1,2] and in the other I store the ids of all the divs using the following snippet
$(".countDiv").each(function(i){
array2[i] = $(this).attr("id");
}
then I use .html()
to write the value of i
into the id of the div by using:
for(var myCount = 0; myCount < array1.length; myCount++){
$("#" + array2[i]).html(array1[i]);
}
The problem is that for all cases its fine, but when i use .
in between the ids, the code doesn't work. No error is showed on the console.
eg: when i use , , it works well, but when i use , the page is blank. The code doesn't work.
Am I doing something wrong here? Any help is appreciated.