好吧我有这个javascript..。
$(document).ready(function() {
$('#holder').toggleClass("visible");
$('a.link').click(function(event) {
// Over-rides the link
event.preventDefault();
// Sets the new destination to the href of the link
newLocation = this.href;
color = $(this).data("color");
$('body').css('background-color', color );
$('#holder').css('opacity','0' );
// Delays action
window.setTimeout(function() {
// Redirects to new destination
window.location = newLocation;
}, 250);
});
$('h1').click(function(event) {
$('#holder').toggleClass("visible");
});
});我有这个html ..。
<body class="landingpage">
<h1 class="begining">Page Tansitions</h1>
<p><a class="link" href="/one.html" data-color="#f36c20">Page One</a></p>
<p><a class="link" href="/two.html" data-color="#edcd40">Page Two</a></p>
</body>..。这一切都很好,而且js做了它的事情,改变了页面的颜色,这是上面代码中的ref 'body‘.
我不想更改html页面的'body‘标记,我想更改一个类,类似于css和html中引用的.我不能为我的生活弄明白如何用javascript来表达它,有人能帮忙吗?
干杯,格雷格。
……此外,我还试图将它集成到一个更复杂的结构中,而现在似乎无法工作.我有html的链接,我使用的是一个平铺类和动画,没有任何改变。
<a class="tile double bg-tile1color live animated flipInX link" data-color="#f36c20" data-role="live-tile" data-effect="slideUp" data-click="transform">当用户单击此瓷砖时,我还使用了javascript触发器,这是我想要插入上述更改页面颜色的javascript的位置.我猜javascript正在覆盖转换.
<script>
$('.tile').on('click', function () {
$(".tile").addClass("flipOutX");
setTimeout(function(){
$(".tile-group.main").css({ marginLeft:"-40px", width: "1080px"}).load("musability-musictherapy-company-overview.html");
}, 2000);
});
</script> 发布于 2015-04-28 23:16:09
使用jquery,您可以使用完整的css选择方法。
$('body').css('background-color', color );可能是这样的
$('.metro .tile-area-darkCrimson').css('background-color', color );发布于 2015-04-28 22:58:53
您可以使用jQuery的addClass
$('body').addClass('metro tile-area-darkCrimson');https://stackoverflow.com/questions/29931373
复制相似问题