【发布时间】:2017-02-08 15:52:12
【问题描述】:
我有一个按钮,当使用 JQuery UI 的 animate() 悬停时,它会改变颜色。单击该按钮时,将加载带有 AJAX 的页面。问题是,一旦我单击该按钮,animate() 似乎不起作用,它只是冻结在一种颜色中。
<!DOCTYPE html>
<html>
<head>
<title>Jquerytest</title>
<link rel="stylesheet" href="styles.css" />
<script src="lib/jquery-3.1.1.js"></script>
<script src="lib/jquery-ui-1.11.2/jquery-ui.js"></script>
<script>
$('document').ready(function() {
var menubutton_animation = 200;
$('.menubutton').hover(function(){
$(this).animate({ color: "#D1571F" }, menubutton_animation);
}, function(){
$(this).animate({ color: "#000000" }, menubutton_animation);
});
$('.menubutton').click(function(){
$('#targetframe').load('portfolio.html');
});
});
</script>
</head>
<body>
<input class="menubutton" type="button" value="Portfolio" id="portfolio">
<div id="targetframe"></div>
</body>
</html>
styles.css 包含以下内容:
@font-face {
font-family: 'Comfortaa';
src: url('Comfortaa.eot'),
url('Comfortaa.ttf') format('truetype');
}
.menubutton {
height:40px;
background:transparent;
border:none;
color:#000000;
cursor: pointer;
font-family:Comfortaa;
font-size:30px;
}
提前谢谢你。
【问题讨论】:
-
点击按钮后开发者控制台是否显示错误?
-
只是这个 XMLHttpRequest 错误:主线程上的同步 XMLHttpRequest 已被弃用,因为它对最终用户的体验产生不利影响。如需更多帮助,请查看xhr.spec.whatwg.org。我不认为这是相关的
标签: jquery ajax jquery-ui load jquery-animate