The problem is that I only get span
element showed when I click on li
not when I hover over li
!
I have something like:
<ul class="nav nav-pills nav-stacked">
@foreach (var category in Model.Categories)
{
<li class="categoryListEl"><a>@category.Name <span style="float:right;display:none"class="badge badge-important">
<button class="close">×</button></span></a></li>
}
</ul>
My Jquery code is:
$(function ()
{
$(".categoryListEl").mouseover(function () {
$this = $(this);
$this.find("span").css("display", "block");
});
$(".categoryListEl").mouseleave(function ()
{
$this = $(this);
$this.find("span").hide();
});;
);
$(function ()
{
$(".categoryListEl").mouseenter(function () {
$this = $(this);
$this.find("span").css("display", "block");
}).mouseleave(function ()
{
$this = $(this);
$this.find("span").hide();
});
});
There's some of syntax error in your code. You might try this code, which always works:
$(function () {
$(".categoryListEl").hover(function () {
$(this).find("span").toggle();
});
});
FIDDLE DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With