【发布时间】:2021-06-22 02:16:35
【问题描述】:
我尝试了这个解决方案,但遗漏了一些东西:change background of parent div on hover
这是我的html:
<div class="box">
<h3 class="page-header item-title">
<a class="titlelink" href="/index.php?option=com_content&view=category&id=11&Itemid=234">
Modeling</a>
这是我尝试在此处覆盖的内容:/templates/shaper_helixultimate/html/com_content/category/default_children.php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
$('.box > .titlelink').hover(function(){
$(this).parent().toggleClass('hover');
})
});
');
我做错了什么?
$('.box > .titlelink').hover(function() {
$(this).parent().toggleClass('hover');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="box">
<h3 class="page-header item-title">
<a class="titlelink" href="/index.php?option=com_content&view=category&id=11&Itemid=234">
Modeling</a>
</h3>
</div>
【问题讨论】:
-
为什么不简单地使用css?
.box a.titlelink:hover{ /* your hover css */ } -
@Kinglish,没有带有 CSS 的父选择器。
标签: javascript joomla hover