2015-10-17 35 views
0

我有这样的代码:

$('#location').html(location); 
$('#temperature').append(temperature); 
$('#temperature').attr("value", temperature); 
$('#weather').html(weather); 
$('#summary').html(summary); 
$('#hourly').html(hourly); 

我想要做的描述是HTML格式的每一个字显示。像这样$('#hourly').html(hourly) + 'next 24 hours' 但是那样做的时候不会显示下24小时描述。

回答

0

如果你想添加一些额外的文本,则需要使用相同的html功能添加:

$('#hourly').html(hourly + 'next 24 hours'); 
+0

他的工作感谢:) –

0

好了,所以这样的:$('#location').html(location);查找一个名为“位置”,所以它可以把变量它的内容在一个具有id="location"属性的HTML元素中。

如果您键入如下内容:$('#location').html('location');字符串“location”将被插入到具有“location”id的元素中。

您可以组合任意数量的变量,字符串和函数作为参数执行:$('#location').html('Current Location: ' + location);(假设“位置”变量包含当前位置的数据)。

如果你想显示当前时间,有关于Date()的文章;功能,可以帮助你做到这一点:Current time formatting with Javascript

+0

非常感谢你 –