TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
First Last
NA
648
72.3k
How to dynamically changing the color of a fontawesome thumb
Aug 20 2020 12:43 PM
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
)
{
// Show by color that it was previously liked.
// Does not work.
$(
".blogLike"
).color(
'green'
);
}
}
function
SetDisLike(disabledSwitch) {
$(
".blogDisLike"
).attr(
'disabled'
, disabledSwitch);
if
(disabledSwitch ==
false
)
{
// Show by color that it was previously liked.
// Does not work.
$(
".blogDisLike"
).color(
'green'
);
}
}
});
</script>
Reply
Answers (
1
)
Nuget command enable-migrations
Profile give error although I install auto mapper ?