[英]Why the jquery news ticker is not working on my website?
我添加到我的主頁embed html並添加了這段代碼/腳本:
<ul class="newsticker">
<li>Etiam imperdiet volutpat libero eu tristique.</li>
<li>Curabitur porttitor ante eget hendrerit adipiscing.</li>
<li>Praesent ornare nisl lorem, ut condimentum lectus gravida ut.</li>
<li>Nunc ultrices tortor eu massa placerat posuere.</li>
</ul>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="js/newsTicker.js"></script>
<script>
$('.newsticker').newsTicker();
</script>
從所有者站點獲取代碼示例:
https://github.com/risq/jquery-advanced-news-ticker
由於我的網站編輯是在weebly.com我已經上傳了js文件。 我試圖改變這一行:
<script src="js/newsTicker.js"></script>
至:
<script src="/files/theme/jquery.newsTicker.js"></script>
試過第一個主題:
到目前為止沒有任何工作。 我在我的網站上有這個文件我上傳了:
jquery.newsTicker.js
jquery.newsTicker.min.js
jquery.ticker.js
腳本應該使文本向上滾動。 但它不起作用。 我沒有看到文本靜態不動。
編輯
這就是我在控制台中得到的:
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.dragndropbuilder.com/files/theme/jquery.newsTicker
Uncaught TypeError: Object [object Object] has no method 'newsTicker' apps/customHtml.php?ucfid=838201711125452969&w=1395277796370&w=139527783313…2562870&w=1395292592083&w=1395292871153&w=1395292967301&w=1395292990574:56
6
Consider using 'dppx' units instead of 'dpi', as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 2), not all, not all, not all, only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx)
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.dragndropbuilder.com/files/theme/jquery.newsTicker.js
Uncaught TypeError: Object [object Object] has no method 'newsTicker' customHtml.php?ucfid=838201711125452969&w=1395277796370&w=1395277833139&w=1395277850426&w=139527788…:56
好像插件的路徑不正確,請再次檢查,或者您可以使用直接鏈接:
<script src="http://risq.github.io/jquery-advanced-news-ticker/assets/js/jquery.newsTicker.js"></script>
代替:
<script src="/files/theme/jquery.newsTicker.js"></script>
以及將jQuery代碼包裝在里面:
jQuery(function($) {
$('.newsticker').newsTicker();
});
在您使用其他JavaScript庫時防止沖突。
去螢火蟲,
在“網絡”選項卡中,檢查是否包含插件腳本js / css。
確保它沒有顯示紅色。
紅色表示沒有獲得正確的路徑,因此出現404錯誤。
順便說一下,這個插件不適用於最近的Jquery版本,最適合1.6。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.