In an aps.net mvc partial view, I have 2 thumbs defined in a paragraph.
The CSS (fontawesome) will change the color to blue when I hover.
Based upon an if statement truth, I want to change the color of the thumbs. The idea being that if the User had previously clicked the Like or Dislike thumb, I want that selection (the thumb) indicated by the color green the next time in. It shows that they already like or disliked it.
How do I dynamically change the color of the thumbs given the way I display them in a paragraph?
- @model GbngWebClient.Models.LikeOrDislikeVM
-
- <style>
- .fa {
- cursor: pointer;
- user-select: none;
- }
-
- .fa:hover {
- color: blue;
- }
-
- .my-size {
- font-size: 20px;
- }
- </style>
-
- <div class="row">
- <p><span class="blogLike my-size fa fa-thumbs-up"></span><span class="my-size"> :
- @Model.LikeCount</span> <span class="my-size"> | </span><span class="blogDisLike my-size fa fa-
- thumbs-down"></span><span class="my-size"> : @Model.DisLikeCount</span></p>
- </div>
-
- @Scripts.Render("~/bundles/jquery")
-
- <script type="text/javascript">
- $(document).ready(function () {
- SetLike('@Model.LikeDisabled');
- SetDisLike('@Model.DisLikeDisabled');
-
- function SetLike(disabledSwitch) {
- $(".blogLike").attr('disabled', disabledSwitch);
-
- if (disabledSwitch == false )
- {
-
-
-
- $(".blogLike").color('green');
- }
- }
-
- function SetDisLike(disabledSwitch) {
- $(".blogDisLike").attr('disabled', disabledSwitch);
-
- if (disabledSwitch == false)
- {
-
-
-
- $(".blogDisLike").color('green');
- }
- }
- });
- </script>