2011-01-14 57 views
0

第一次訪問這個頁面,將鼠標懸停在菜單: http://milabalami.com/saved/2/index.php的Javascript問題與easyslider

然後訪問這個WordPress網頁,我已經實現了完全相同的代碼:當你將鼠標懸停 http://milabalami.com

在Wordpress菜單中,您將看到滑塊不顯示。爲什麼?我可以看到頁面給出了一個錯誤:

$ is not a function 
http://miladalami.com/wp-content/themes/sandbox/js/custom.js 

這是爲什麼?它完全相同的代碼在另一頁上完美工作。我不明白爲什麼它在Wordpress頁面上給出該錯誤,而不是在滑塊工作的另一個上。任何人都可以幫助我解決這個難題?

益江解決了難題。

+0

你的頁面沒有使用相同的CSS:一個沒有`#blackbox {0}位置:絕對; \t left:0px; \t top:auto; \t寬度:自動; \t height:50px; \t z-index:2; \t background-color:#000000; \t margin-top:auto; \t margin-right:0px; \t margin-bottom:0px; \t margin-left:0px; \t right:0px; \t bottom:0px; }` – Shikiryu 2011-01-14 17:00:47

+0

#blackbox是完全不同的東西。所有的CSS代碼已被添加到WordPress的一個。所以沒有問題。任何其他想法?它必須與我得到的那個錯誤有關... – Alehandro 2011-01-14 17:02:24

回答

1

它看起來像一路上,$被覆蓋。你仍然可以使用自己的代碼,但是,通過使用jQuery,而不是$ -

jQuery(document).ready(function($) { 
    $("#featured").easySlider({ 
     speed: 400 
    }); 

    $("#menu ul li a[class!='current']") 
    .css({backgroundPosition: "200px 2px"}) 
    .mouseover(function(){ 
     $(this).stop().animate({backgroundPosition:"(0 2px)"}, {duration:400}) 
    }) 
    .mouseout(function(){ 
     $(this).stop().animate({backgroundPosition:"(200px 2px)"}, {duration:400}) 
    }) 
}); 

這是一個權宜之計,但是。您應該將所有代碼合併到一個文件中,而不是像現在一樣將它們分開,並減少對插件的依賴。