0

I have an arrow on the maincategory if a particular category has subcategory, iam using jquery animation to slideup, slidedown subcategory. i want to remove previous arrow and replace it with different arrow when the subcategories slidesdown

Here is my Jquery code for Reference:

$(document).ready(function () {
    $("aside ul li:has(ul)").addClass("ic-arrdn");
    var e = $("aside > ul > li.current-cat, aside > ul > li.current-cat-parent");
    if (e.length == 1) {
    }
    $("aside > ul > li > ul.children").each(function () {
        $(this).find("li")
        $(this).parent().toggle(function () {
            $(this).find("ul").slideDown()
        }, function () {
            $(this).find("ul").slideUp()
        })
    })
});

This the markup:

-<ul>
    <li class="cat-item cat-item-6797 ic-arrdn"><a href="http://johndoe.com/cat1">Cat 2</a><span>(234)</span>
        <ul class="children">
            <li class="cat-item cat-item-7492"><a href="http://johndoe.com/cat1-sub" title="View all posts filed under cat1">Cat 1</a><span>(1)</span>
            </li>
        </ul>
    </li>
</ul>

I Add the Class ic-arrdn if there are subcategories in the category, then if the main category is clicked i want the class to change from ic-arrdn to ic-arrup..

0

I added these lines: $(this).removeClass('ic-arrdn').addClass('ic-arrup'); $(this).removeClass('ic-arrdn').addClass('ic-arrup');

and achieved the result.

$(document).ready(function () {
        $("aside ul li:has(ul)").addClass("ic-arrdn");
        var e = $("aside > ul > li.current-cat, aside > ul > li.current-cat-parent");
        if (e.length == 1) {
        }
        $("aside > ul > li > ul.children").each(function () {
            $(this).find("li")
            $(this).parent().toggle(function () {
                $(this).find("ul").slideDown();
                $(this).removeClass('ic-arrdn').addClass('ic-arrup');   
            }, function () {
                $(this).find("ul").slideUp();
                $(this).removeClass('ic-arrdn').addClass('ic-arrup');   
            });
        });
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.