a {
text-decoration: underline;
cursor: pointer;
}
JavaScript
$('.button').click(function(){
// var col_settext1 = new Array(); <-- I need make this array with name of DIV cliked
col_settext1['field_id1']='#FF0000';
col_settext1['field_id2']='#00FFFF';
// var txt_settext1 = new Array(); <-- I need make this array with name of DIV cliked
txt_settext1['field_id3']='Some Text Here';
txt_settext1['field_id4']='Another Text Here';
// var txt_settext2 = new Array(); <-- I need make this array with name of DIV cliked
txt_settext2['field_id5']='Some Text Here';
// var col_settext2 = new Array(); <-- I need make this array with name of DIV cliked
col_settext2['field_id6']='Another Text Here';
// var chk_settext2 = new Array(); <-- I need make this array with name of DIV cliked
chk_settext2['field_id7']="checked";
$myclass = this.id;
$col = 'col_' + $myclass;
$txt = 'txt_' + $myclass;
$chk = 'chk_' + $myclass;
// Based on click link 'settext1', Here I have this:
// col_settext1
// txt_settext1
// chk_settext1
// THE PROBLEM ARE HERE!
$col = new Array(); // <--- Here I use name of DIV as Array
$txt = new Array();
$chk = new Array();
// Test...
alert($col); // <--- Here no have any value :(
alert($col[1]); // <--- Here no have any value :(
for (id in $col) { // 'id' is value of array --> col_settext1['field_id1']='#FF0000';
// do function based on array values...
// just example:
alert(id);
}
for (id in $txt) { // 'id' is value of array --> txt_settext1['field_id1']='#FF0000';
// do function based on array values...
}
for (id in $chk) { // 'id' is value of array --> chk_settext1['field_id1']='#FF0000';
// do function based on array values...
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.