Jq problem. After ajax submits the event, the content is triggered twice. Why is that?

console.log() .

this is all the code of js. Please have a look at it if you have time. Thank you.

Feb.27,2021

obj.click (function () {.}) this is written in the $.each (obj,.) method, obj=$ ('li.CE-display') . Will this selector select multiple elements? if there are multiple elements, then the click event here will be bound multiple times, so it will be triggered multiple times.


may also trigger the default event


$.each (obj, function () {obj = $(this)}) although it doesn't have much effect on the result here, it's easy to get confused when reading the program. function Internal recommendation is to declare a new local variable const $obj = $(this) .

there's nothing wrong with the code, so

  1. are you sure Ajax is causing the problem? Use simple console.log (1) , console.log (2) to track the branches to see what the results are
  2. .
  3. DisplayVluae () is there another place to call?

Thank you for the invitation.

The

code uses stickers, which is not very friendly to mobile users. In addition, if the code is not given to the structural part of HTML, some problems may be ignored.

There is no obvious problem in the

code, but it is not recommended to use each in conjunction with events (in this case, click). This requirement is generally solved by event proxies. In addition, user-triggered actions (click in this case) and ajax are not recommended to be written together, and an anti-shake or flag bit is generally added as a limit to avoid repeated triggers within a short period of time. Besides, you don't seem to see the instructions for the use of the scene? The click on the mobile side does have a 300ms delay and repeat trigger, which is a bit like yours.


is this the reason why events bound by on need to be unbound to prevent events from bubbling?

$(selector).unbind(event,function)

Thank you for your comments. The problem no longer exists. I didn't move anything last night. I just came up to debug today and didn't change anything.?:)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c617-2baff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c617-2baff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?