0

i'm working with asp mvc 5

I have a javascript function that applies an action on a given class, for applied this function on a class I use the keyword this by being in this class, my problem is that I do not know how to use this function in any class at the same time, this is my javascript

    function flipCard_1(el, dir) {
    var flipcard = el.closest('div[class|="fsc-comp-flipcard"]');
    if (dir == 1) {
        var card_new_h = flipcard.children('div[class|="fsc-comp-card"]').eq(1).height();
        flipcard.css('height', card_new_h).addClass('flipped');
    }
    else {
        var card_new_h = flipcard.children('div[class|="fsc-comp-card"]').eq(0).height();
        flipcard.css('height', card_new_h).removeClass('flipped');
    }
}

I want that el supports any class that FSC-comp-card and applies javascript totu the same time

3 Answers 3

2

You are not using Class Selector (".class") properly.

Use

el.closest('div.fsc-comp-flipcard')

instead of

el.closest('div[class|="fsc-comp-flipcard"]')
Sign up to request clarification or add additional context in comments.

Comments

1
var flipcard = el.closest('[class=fsc-comp-flipcard]');

Comments

0

I want change the key word "this" which allow me to apply javascript on the current class, by something which allow me to applie the javascript on all class

 <button type="button" class="btn fsc-btn-2" onclick="flipCard_1(jQuery(this), 1);">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.