我有 2 个问题
我正在使用 hashchange 插件...所以我想知道每次发生 hashchange 时都会调用下面的函数...因为我的代码和代码函数中有类似的东西显然似乎没有被称为
$(文档).ready(function()
{
// 这里的函数
});
另一方面,如果我删除 hashchange,就像如果我做 http://abc.com/a.htm#http://abc.com/b.htm 为
问题是我的页面结构有点不同......这是页面结构的小提琴,它在更高的层次上解释了我想要实现的目标 jsfiddle.net/vBKWd/9 ...在哈希更改时,我第 1 页上的 div c 被第 2 页替换,反之亦然 ....和我展示的 js 函数下面只被调用一次,而不是在 hashchange 之后
调用或者有什么方法可以将函数与 div 绑定,这样每当 div 被替换时,函数就会被调用?
I have 2 questions
-
I am using the hashchange plugin .... so I want to know would a function as below, be called everytime a hashchange occurs... because I have something like that in my code and the code function apparently doesnt seems to be called
$(document).ready(function()
{
// function here
});
-
On the other have if I remove the hashchange as in If i make http://abc.com/a.htm#http://abc.com/b.htm as http://abc.com/b.htm
the code works fine
the problem is the structure of my pages is a bit different .... here is the fiddle with the page structure that explains on a higher level what I am trying to achieve jsfiddle.net/vBKWd/9 ... on hash change jus the div c on my page 1 gets replaced by page 2 and vice versa .... and the js function that I have shown below is getting called only once and not after hashchange
Or is therre any way I can bind the function with the div so that whenever the div is replace the function get called?
发布评论
评论(3)
不,就绪处理程序仅在文档就绪时调用,而不是在哈希更改时调用。您应该使用
hashchange
事件来代替:示例:http://jsfiddle。净/vBKWd/2/
No, a
ready
handler is only called on document ready, not on hash change. You should use thehashchange
event for that, instead:Sample: http://jsfiddle.net/vBKWd/2/
在下面的文档中准备好编写代码
In document ready wirte code below
在这种情况下使用
live
use
live
in this case