Native js implements the function of replying to comments and js comments.

Source: Internet
Author: User

Native js implements the function of replying to comments and js comments.

Implementation Principle

Function 1. Deletion Status

Use the removeChild () method.

Function 2. Top likes

Determine whether the text content is likes and modify the container text content that stores likes.

Function 3. reply to comments

Create a new comment and add it to the comment list.

Function 4. Click like in the reply

Determine if I have liked the image and perform the corresponding operations.

Function 5. Reply or delete

Determine whether the string is replied or deleted and perform the corresponding operation

The Code uses event proxies and triplicate operations to reduce the amount of code.

Each line of code has a detailed comment

Don't get bored with seeing so many codes at a glance

In fact, it is a very simple dom operation to view each function separately.

A little bit of digestion, read every line of code

Complete code

Note: copy the code to the local directory and replace the part.

<! DOCTYPE html> 

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.