繁体   English   中英

如何为变量添加样式?

[英]How to Add Styling to Variable?

如何为文字添加样式第一季/第二季/第三季 ...”? 这是我当前正在使用的代码:

$(document).ready(function()
{
var data = [
{text: 'Season One', url: "/Season?open=1"},
{text: 'Season Two', url: "/Season?open=2"},
{text: 'Season Three', url: "/Season?open=3"},
{text: 'Season Four', url: "/Season?open=4"},
{text: 'Season Five', url: "/Season?open=5"}
];
$('#SeasonInput').autocomplete(data,
{
formatItem: function(item)
{ 
return item.text;
} 
}).result(function(event, item)
{
location.href = item.url;
});
});

我尝试了.css({'margin: 0', 'background-color: white'})和其他变体,但没有成功。

您的.css错误。 它必须是以下对象: .css({margin: '0', 'background-color': 'white'})
{key: value, key: value}'在key周围的'如果不包含-则可以省略)。

您的代码.css({'margin:0','background-color:white'})的问题。 试试这个$('#SeasonInput')。css({margin:0,backgroundColor:'white'}); 当您将其作为对象的属性时,则不需要在名称中使用双精度代码,而在值中需要使用双精度代码,例如backgroundColor:'white'。 简单而聪明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM