Javascript/Jquery还在搞清楚.但是,有谁能告诉我,为什么除了IE8之外,以下代码在每个浏览器和操作系统中都能工作呢?在JQuery上使用最新版本。( Wordpress站点的片段)
$(document).ready(function(){
var current = <?php the_ID() ?>;
var currentEl = $("#project-link-"+current).addClass('active');
var prev = currentEl.prev();
if(prev[0] != undefined){
$("#prev-link").attr('href',$(prev[0]).attr('href'));
}else{
$("#prev-link").hide();
}
var next = currentEl.next();
if(next[0] != undefined){
$("#next-link").attr('href',$(next[0]).attr('href'));
}else{
$("#next-link").hide();
}
$(window).hashchange( function(){
$(".project-image.active").removeClass('active');
var num = window.location.hash.substring(1);
changeImage(num);
});发布于 2013-01-09 16:33:01
建议
hashChange()可能无法在IE中工作!https://stackoverflow.com/questions/14241787
复制相似问题