Home  >  Article  >  Web Front-end  >  What should I do if the jquery element cannot be found?

What should I do if the jquery element cannot be found?

藏色散人
藏色散人Original
2021-11-11 09:15:562120browse

The jquery element cannot be found solution: 1. Check the corresponding code file; 2. Check the error through debug; 3. Just remove the dot in the id.

What should I do if the jquery element cannot be found?

The operating environment of this article: windows7 system, jquery version 3.2.1, DELL G3 computer

What should I do if the jquery element cannot be found?

jquery cannot get the specified element using $

The specific code is as follows:

var id='#'+screen.timeleft
var timeCountDown = $(id);

Then timeCountDown has always been empty. After debugging, I found:

What should I do if the jquery element cannot be found?

The reason is that the id contains "." After removing it, the element is found

var id='#'+screen.timeleft.replace(/\./g, "").replace(/\:/g, "").replace(/\-/g, "")
var timeCountDown = $(id);

and then everything is normal.

Recommended learning: "jquery video tutorial"

The above is the detailed content of What should I do if the jquery element cannot be found?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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