For a demonstration, please check out this jsfiddle: jsfiddle.net/rflfn/uS4jd/
Here is another attempt: jsfiddle.net/rflfn/T3ZT6/
I am utilizing SMOF to build a Wordpress theme. I need to create a function that changes certain values when a link is clicked. However, when I try to create an array with the name of the div, it returns a null value...
HTML:
<a class="button" id="settext1">Some Link</a>
<br />
<a class="button" id="settext2">Another Link</a>
<br />
<a class="button" id="settext3">Link 3</a>
<br />
jQuery:
$(document).ready(function(){
col_settext1['field_id1']='#FF0000';
col_settext1['field_id2']='#00FFFF';
txt_settext1['field_id3']='Some Text Here';
txt_settext1['field_id4']='Another Text Here';
txt_settext2['field_id5']='Some Text Here';
col_settext2['field_id6']='Another Text Here';
chk_settext2['field_id7']="checked";
});
$('.button').click(function(){
$myclass = this.id;
$col = 'col_' + $myclass;
$txt = 'txt_' + $myclass;
$chk = 'chk_' + $myclass;
// Issue arises here!
$col = new Array();
$txt = new Array();
$chk = new Array();
alert($col);
alert($col[1]);
for (id in $col) {
alert(id);
}
for (id in $txt) {
}
for (id in $chk) {
}
});
Is it possible to use the name of the div as an array name? Any suggestions or alternative methods to solve this issue are appreciated.