1

I would like to add css class inside a view and later call it.

Something like this:

<style>
  MarkSelectedRow {
    background-color: cornflowerblue;
  }
</style>

I was trying to call that class:

  var MarkSelected = function (element) {

    var tdCaller = $(element);
    tdCaller.addClass("MarkSelectedRow");

  }

But, nothing happens. It seems like class is not defined. Is it possible to define class inside <style></style> and later use it in code?

2
  • 3
    you need a . before it: .MarkSelectedRow {} Commented Feb 7, 2017 at 12:10
  • 1
    This has got nothing to do with razor :) Commented Feb 7, 2017 at 12:10

1 Answer 1

4

You miss the dot:

<style>
   .class_name {
      background-color: cornflowerblue;
    }
</style>
Sign up to request clarification or add additional context in comments.

4 Comments

you are right, thanks. Why downvoting on this? Explanation, please.
@FrenkyB I didn't downvote, otherwise I forgot to vote, but thumbs up
somebody downvoted on your post. My question was to him / her.
It was me but it had to be an upvote, edited just to undo that!

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.