How JQuery implements the functions of click to follow and unfollow
Like, an Internet term that means "agree" and "love".
This Internet slang comes from the "like" function of online communities. The number of likes you send and receive, your preferences for giving likes, etc., can to some extent reflect who you are and what state you are in. Behind the likes, you are reflected. Corresponding to this is the cancel function. It just so happened that the blogger recently worked on an APP, and one of the sections needed to implement the like and cancel functions. After thinking about it, he decided to use JQuery code to implement it. Okay, without further ado, let’s get down to the practical stuff! !
First we need to introduce the JQuery plug-in
Secondly, we need to define a div and give it some styles
Then there is the JS code, as shown below
$(document) .ready(function(){
var onOff=true;
var div=$(".div");
div.click(function( ){
if (div.onOff) {
div.val("Follow me");
div.css({"background":'#ccc' });
div.onOff = false;
} else {
div.css({"background":'red'});
div.val("Already followed");
div.onOff = true;
}
});
});
The effect is as follows
It can be seen that the JS code is easy to use, the same , you can also achieve the image switching effect as shown below
The implementation code is as follows
html:
##css: Pay attention to the image path .div{
The above is the detailed content of How JQuery implements the functions of click to follow and unfollow. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



When placing orders using Meituan, users can choose to cancel the orders they do not want. Many users do not know how to cancel Meituan orders. Users can click on the My page to enter the order to be received, select the order that needs to be canceled and click Cancel. How to cancel an order with Meituan 1. First, click on Meituan My Page to enter the order to be received. 2. Then click to enter the order that needs to be canceled. 3. Click Cancel Order. 4. Click OK to cancel the order. 5. Finally, select the reason for cancellation according to your personal situation and click Submit.

1. The ear symbol is the voice receiver mode. First, we open WeChat. 2. Click me in the lower right corner. 3. Click Settings. 4. Find the chat and click to enter. 5. Uncheck Use earpiece to play voice.

When many users experience Mango TV, a video software, they choose to become members in order to enjoy more film and television resources and more comprehensive services. In the process of using Mango TV membership services, some users will choose to turn on the automatic renewal function to enjoy the discounts to ensure that they will not miss any exciting content. However, when users no longer need membership services or want to change the payment method, canceling the automatic renewal function is a very important thing to protect the safety of property. How to cancel the automatic renewal service of Mango TV? Users who want to know Come and follow this article to learn more! How to cancel the automatic renewal of membership on Mango TV? 1. First enter [My] in the Mango TV mobile APP, and then select [VIP Membership]. 2. Then find [Tube

1. Click the [iTunesStore and AppStore] option in the phone settings. 2. Click [View AppleID], and then enter the login password. 3. Enter the [Account Settings] interface and click [Payment Information]. 4. Check the payment method as [None] and click [Finish]. After completion, return to the WeChat interface. At this time, you will receive the [Successful Cancellation Notification] message, and WeChat will no longer automatically deduct fees.

Why don’t others see my attention on Weibo? We only need to classify the blogger into the group "Follow quietly" so that others will not see that we are following him. 1. Open Weibo on your mobile phone and click [Follow] on the homepage. 2. Click [Follow quietly] in "My Group". How to check visitor records on Weibo? 1. The visitor recording function tested on Weibo is currently only visible to SVIP and VVIP, and is only open to some users. 2. Users can find the visitor record entrance in [More Functions] under the personal center, where they can view the number of visitors, the visitors, and the people who visit more frequently. 3. This function is only open to SVIP and VVIP users, and is temporarily unavailable to ordinary users and ordinary member users. 4. In short, Weibo test visitors

Alipay is a very practical life service platform. This software is very powerful. It provides users with functions such as life payment, travel, medical insurance, etc., bringing convenience to everyone's life. The Alipay platform has many functions waiting for everyone to unlock, so how do you cancel face-swiping payment on Alipay? Detailed tutorial on canceling face-swiping payment on Alipay: 1. First open Alipay 2. Click on My in the lower right corner 3. Click on Settings in the upper right corner 4. Click on payment settings 5. Click on biometric payment 6. Find the mobile phone to scan the face to pay 7. Uncheck the software features 1. Support various scene relationships, group chat and group payment are more convenient; 2. Establish family accounts for children and parents; 3. Free long-distance inter-bank transfers and credit card repayments

As a well-known short video e-commerce platform in China, Doudian provides merchants with convenient sales channels and a broad user base. On Doudian, merchants need to deliver goods in time to meet users' shopping needs, but sometimes due to various reasons, merchants may need to cancel shipments within 48 hours. So, how does Doudian cancel shipments within 48 hours? 1. How to cancel delivery within 48 hours on Doudian? Merchants can cancel shipments in Doudian's backend management system. After logging in to the backend management system, merchants can easily find the orders that need to be canceled and select the corresponding orders for operation. By clicking the Cancel Shipping button, the system will pop up a prompt to confirm the cancellation. After the merchant confirms, the order can be successfully canceled. This operation applies to orders shipped within 48 hours

Fliggy Travel allows everyone to easily purchase tickets online. Everyone can get great convenience here. It is very simple to use. It provides a variety of travel methods, and hotels can be booked. Every trip can be made here in advance. Prepare everything, and every travel experience is very good. Many people buy air tickets here, and they will find that there is a cost every time, which is a delay-free gift package. The function of this gift package is that after the flight is delayed, it will be time, we will compensate you, but if there is no delay, this service will be of no use at all. In today's society, delays are relatively small, so it is generally useless. Here, the editor provides you with a cancel-no-buy service. If you don’t want to buy it, you can check it out to find out how to pack it.
