【问题标题】:Jquery back button not working when animation is used使用动画时,Jquery后退按钮不起作用
【发布时间】:2015-03-06 04:55:38
【问题描述】:

我尝试将背景图片放到我的页面中,并且我尝试使用 css 类,但它不起作用。它工作的唯一方法是通过样式标签。 但是当我将它与动画一起使用时,它不起作用。 这是我的代码 sn-p。

<div data-role="page" id="three" style="background:url('background1.jpg') repeat-x; -webkit-animation: animateBackground 15s infinite;">
        <div  id="1"><img  src="cake.png" alt="where is my cake?" /></div>
        <div  id="2"><img  src="cake.png" alt="where is my cake?" /></div>
        <div  id="3"><img  src="cake.png" alt="where is my cake?" /></div>
       <button id="startShuffle">click</button>  
</div>

CSS:

@-webkit-keyframes animateBackground {
    from { background-position: 0 0; }
    to { background-position: 100% 0; }
}

请告诉我这样做的方法或更改 jquery 页面背景图像的任何其他方法。

【问题讨论】:

  • 你能发一个 JSFiddle 吗?
  • dude 发布整个代码。我无法做出决定
  • jQuery 和这里有什么关系?您的代码中没有显示 JQuery 甚至任何 javascript。请提供正确(详细)的问题描述和预期结果。

标签: javascript jquery css jquery-mobile tizen


【解决方案1】:

我做了一个小提琴,为我工作。

https://jsfiddle.net/43ny6zna/

我将上面的代码从我之前的答案更改为:

 parent.history.back();  --> window.history.back();

背景显示为动画,后退按钮有效。

可能背景无法正常工作,因为实际图像位置不匹配。也许它与 html 文件位于不同的文件夹中。

所以我用链接替换了它,代码运行良好,可以加载背景。

最后,

您是否已将 jQuery 库加载到您的页面中?将此:&lt;script src=code.jquery.com/jquery-1.11.2.js&gt;&lt;/script&gt; 添加到您的 HTML 文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多