lundi 3 février 2020

How can one use CSS in an if statement of JavaScript code?

I have a Vue.js component and I want to use this CSS part when the if conditon is true:

<style type="text/css">  
 #sideNavBox {DISPLAY: none}  
 #contentBox {MARGIN-LEFT: 5px}  
</style> 

Here's the JavaScript:

IsCurrentUserMemberOfGroup("Admins", function (isCurrentUserInGroup) {
    if(isCurrentUserInGroup) {
        for (var i = 0; i < data.length; i++) {
            $this.teams.push({
                id: data[i].ID,
                TeamName: data[i].TeamName.TeamName,
                Coach: data[i].Coach,
                CoachTel: data[i].CoachTel,
                CoachAddress: data[i].CoachAddress,
                CoachAssistant: data[i].CoachAssistant,
                CoachAssistTel: data[i].CoachAssistTel,
                CoachAssistAddress: data[i].CoachAssistAddress,
                Email: data[i].Email
            });
        }
        console.log("Works!")
    }
});

I could add the CSS part in

<style>
</style>

but then it would be used all the time.

How can one use the CSS part if the if statement is true?

Aucun commentaire:

Enregistrer un commentaire