这段代码可以在主页上运行,但不能在任何其他页面上运行,我不明白其中有什么问题。
在 codeigniter 配置文件中“csrf_protection”也是 FALSE。
JQUERY
$(document).ready(function () {
$("#services").hover(
function () {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideDown("fast");$(this).toggleClass('open');},
function () {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideUp("fast");$(this).toggleClass('open');}
);
});
HTML
<li id="services" class="dropdown" data-wow-delay="0.2s"><a <?= active('services') ?> data-toggle="dropdown" href="#">Services</a>
<ul class="dropdown-menu" role="menu">
<li><a href="<?= base_url('services/dry-cleaning') ?>">Dry Cleaning</a></li>
<li><a href="<?= base_url('services/fluff-fold') ?>">Fluff & Fold</a></li>
<li><a href="<?= base_url('services/wedding-gowns') ?>">Wedding Gowns</a></li>
<li><a href="<?= base_url('services/drapery') ?>">Drapery</a></li>
<li><a href="<?= base_url('services/table-bed-linens') ?>">Table & Bed Linens</a></li>
<li><a href="<?= base_url('services/alterations') ?>">Alterations</a></li>
<li><a href="<?= base_url('services/purse-rug-leather-cleaning') ?>">Purse | Rug | Leather Cleaning</a></li>
</ul>
</li>
最佳答案
一个可能的解释是您已在主页上包含 jquery 库,但在其他页面上未包含该库。尝试一下
$("document").ready(function(){
alert("Alerted Text");
});
在主页以外的任何页面上查看 jQuery 是否正常工作
关于javascript - 下拉 JQuery 在没有主页的情况下无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31956710/