武家辉 武家辉 - 1 month ago 18
jQuery Question

The appendTo() function in js didn't work

I met a problem with js. The js function appendTo() is not work!
my js code is like this:
enter image description here

my browser console shows that everythings is as planed:
enter image description here

here is the problem , my html element tbody doesn't contain any things as followed:
enter image description here

why? how can i fix this?

Answer

Although HTML id is allowed to contain dot and colon characters, the fact that you are using jQuery makes it doesn't work because dot and colon have special meaning in a a selector context.

The following native JS will work:

document.getElementById('tb_10.3.3.186:32222').innerHTML += html;

But if you still want to use jQuery, you need to remove the dot (.) and colon (:) from your id.

Comments