I am going to call the elements of the following array into jquery.
$options[] = array( 'title' => 'Upload Favicon',
'id' => 'favicon',
'type' => 'upload' );
I have tried the following, but it does not work..
jquery("'.$option['id'].'").hide();
May be I am wrong, but I myself guess that it is because in the jquery code there is no # for id calling, but I do not know how to add #.
Please help..
1 Answer 1
The obvious problem is here:
$options[] = array( 'title' => 'Upload Favicon',
^^
This says "add an element to the array $options, and set that element's value to the array 'title' => 'Upload Favicon'.... If $option is not yet set, it will be created as an array. So it will effectively be like this:
$options = array (
array ('title' => 'Upload Favicon',
'id' => 'favicon',
'type' => 'upload'
);
);
This probably isn't what you mean, simnce you'll need to access it like this:
$options[0]['id']
To fix it, remove the []:
$options = array( 'title' => 'Upload Favicon',
'id' => 'favicon',
'type' => 'upload'
);
2 Comments
jquery("'.$option['id'].'").hide(); it has 2 errors on jQuery alone.
jQuery("#'.$option['id'].'").hide();I guess?