我有一个JS文件,它接受HTML页面的值。我必须在JS内嵌的CSS中使用这个变量

时间:2013-03-12 10:36:26

标签: javascript jquery css html5 css3

我正在使用simplemaps这是一个js文件,其中一个函数用于从HTML页面获取值。

Javascript功能

function getValue(intvalue){
alert(intvalue);
var mapval = intvalue;
}
var simplemaps_worldmap_mapdata = {


main_settings:{
//General settings
width:1004,
background_color: '#FFFFFF', 
background_transparent: 'no',
border_color: '#FFFFFF',
zoom: 'yes',
pop_ups: 'detect', //on_click, on_hover, or detect

//Country defaults
state_description:   'Country description',
state_color: '#88A4BC',
state_hover_color: '#3B729F',
state_url: 'http://simplemaps.com',
all_states_inactive: 'no',

//Location defaults
location_description:  'Location description',
location_color: '#FF0067',
location_opacity: 1,
location_url: 'http://simplemaps.com',
location_size: 35,
location_type: 'circle', //or circle
all_locations_inactive: 'no',

url_new_tab: 'no',  
initial_zoom: 1,   
initial_zoom_solo: 'no',
auto_load: 'yes',
hide_labels: 'no'  
},
}//end of simplemaps_worldmap_mapdata

我必须动态地将值传递给'initial zoom',colors字段。在不同的值,它会在不同的级别缩放图像。

1 个答案:

答案 0 :(得分:0)

我不明白你究竟在问什么,但我想你需要访问main_settings对象

您可以通过

访问对象中的属性

simplemaps_worldmap_mapdata.main_settings.initial_zoom

simplemaps_worldmap_mapdata["main_settings"]["initial_zoom"];

read this