0

Is there anyway I can change this inline razor conditional statement so that the class attribute isn't always output to the html unless the class is actually being added. I don't want my html to have class="" in it.

<div id="wrapper" class="@(isMobile ? "mobileView" : "")">

1 Answer 1

2

What about

<div id="wrapper" @(isMobile ? "class=\"mobileView\"" : "")>
Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work : it shows error "Missing attribute name"

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.