On document ready, I am trying to create an object for all my div(s) in a class and assigned them based on the div’s attribute ‘id’. Here are my codes which doesn’t work, I can’t figure out.
<div class="supercolor" >
<div class="colordiv" id="#111111" style="background-color:#111111;"> </div>
<div class="colordiv" id="#222222" style="background-color:#222222;" > </div>
<div class="colordiv" id="#333333" style="background-color:#333333;"> </div>
</div>
And in my script section.
$(document).ready(function() {
$('div.supercolor > div').each(function() {
var color_object = { $(this).attr('id') : false }
});
});
Thank you
This will take all your
<div>‘s and map them to div objects. You can pass in data from your individual<div>like the id and pass it to the constructor.You have to call
.get()to get out an array.[Edit]
This code snippet may look more familiar though