gpt4 book ai didi

jquery - 使用 jQuery 删除 css 属性

转载 作者:太空宇宙 更新时间:2023-11-04 13:46:49 25 4
gpt4 key购买 nike

我在尝试使用 .js 文件中的 jQuery 删除 css 属性时遇到了一些问题:

 generateContent: function (point) {
$(".gm-style-iw .table-round .rows .col").css({ 'transform' : 'none !important' });
var key = point.key;
var area = point.area;
var update = point.update;
var carparks = point.carparks;

var content = '<div class="table-round"><div class="header">' + area + '</div><div class="rows"><div class="row row-header"><div class="col center">Development</div><div class="col center">Available Lots</div></div>';
for (var key2 in carparks) {
var carpark = carparks[key2];
var name = carpark.name;
var lots = carpark.lots;
var objectId = carpark.objectId;

content += '<div class="row"><div class="col">' + name + '</div><div id="rtpLot' + objectId + '" class="col center bold">' + lots + '</span></div>';
}
content += '</div><div class="footer">Last updated: <span class="lastUpdate">' + update + '</span></div></div>';
return content;
},

我的 CSS 类如下所示:

.gm-style-iw .table-round { padding: 15px 20px; width: 300px; }
.gm-style-iw .table-round .header { font-size: 32px; font-weight: bold; margin: 0 0 15px; }
.gm-style-iw .table-round .rows { color: #333; background: #eee; }
.gm-style-iw .table-round .rows .row { border-top: 1px solid #fff; }
.gm-style-iw .table-round .rows .row-header { background: #495b67; }
.gm-style-iw .table-round .row-header .col { color: #fff; font-weight: bold; }
.gm-style-iw .table-round .rows .col { display: inline-block; padding: 10px 15px; width: 120px; font-size: 18px; position: relative; top: 50%; transform: translate(-50%,-50%); vertical-align: top; }
.gm-style-iw .table-round .rows .bold { font-weight: bold; }
.gm-style-iw .table-round .rows .center { text-align: center; }
.table-round .footer { font-size: 13px; font-style:italic; text-align: right; padding: 10px 0 0; background-color: #FFF; }

基本上它在 chrome 上运行良好,但在 IE 上运行不佳。我想知道为什么会这样?

提前致谢。

编辑

var content = '<div class="table-round"><div class="header">' + area + '</div><div class="rows"><div class="row row-header"><div class="col center">Development</div><div class="col center">Available Lots</div></div><div></div>';
for (var key2 in carparks) {
var carpark = carparks[key2];
var name = carpark.name;
var lots = carpark.lots;
var objectId = carpark.objectId;

content += '<div class="row"><div class="col">' + name + '</div><div id="rtpLot' + objectId + '" class="col center bold">' + lots + '</div></div>';
}
content += '<div class="footer">Last updated: <span class="lastUpdate">' + update + '</span></div>';
return content;

最佳答案

您的 HTML 格式不正确,这是一个修复方法:

    var content = '<div class="table-round">' +
'<div class="header">' + area + '</div>' +
'<div class="rows">' +
'<div class="row row-header">' +
'<div class="col center">Development</div>' +
'<div class="col center">Available Lots</div>' +
'</div>';
for (var key2 in carparks) {
var carpark = carparks[key2];
var name = carpark.name;
var lots = carpark.lots;
var objectId = carpark.objectId;

content += '<div class="row">' +
'<div class="col">' + name + '</div>' +
'<div id="rtpLot' + objectId + '" class="col center bold">' + lots + '</div>' +
'</div>';
}
content += '</div>' +
'<div class="footer">Last updated: <span class="lastUpdate">' + update + '</span></div>' +
'</div>';
return content;
},

对于你的css,你可以试试:

$(".gm-style-iw .table-round .rows .col").css({ '-ms-transform' : 'none !important' });

或者:

$(".gm-style-iw .table-round .rows .col").attr('style', function(i,s) { return s + 'transform: none !important; -ms-transform: none !important;' });

或者:

$('.gm-style-iw .table-round .rows .col').css('cssText', 'transform: none !important');

关于jquery - 使用 jQuery 删除 css 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22468529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com