Home > Web Front-end > JS Tutorial > body text

How to make text change color after click in Vue

亚连
Release: 2018-06-06 10:22:53
Original
6408 people have browsed it

Below I will share with you a Vue method to implement text color change after clicking. It has a good reference value and I hope it will be helpful to everyone.

Use text as an example here, the principle of image switching is the same.

The general idea is: Use two spans with the same class to switch respectively. The text before and after has the same class, mainly to change the position of the text before and after to be the same. Then use the click event to control their visibility.

The code is as follows:

HTML:

<span class="response" v-show="!showCommentInput" @click="showCommentInput = !showCommentInput">回复</span>
<span class="response" v-show="showCommentInput" @click="showCommentInput = !showCommentInput">回复</span>
Copy after login

JS:

data(){
 return {
  showCommentInput = false,
 }
}
Copy after login

CSS:

.response {
 font-size:14px;
 color: #3e3e3e;
 &:hover{
 font-weight: bold;
 }
 &+.response {
 font-weight: bold;
 }
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Solving the problem of hot deployment not detecting file changes in Webpack

In webpack-dev-server Achieve automatic page update

Achieve magnifying glass through jquery technology

The above is the detailed content of How to make text change color after click in Vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!