比如说var div = document.creatElement("div");
var p = document.creatElement("p");
div.appendChild(p);这样,我不把div添加到html结构中,有办法通过document.getElementByTagName或者jquery选择到这个p么?
var p = document.creatElement("p");
div.appendChild(p);这样,我不把div添加到html结构中,有办法通过document.getElementByTagName或者jquery选择到这个p么?
var p = document.creatElement("p");
p.setAttribute('id','SignP');
div.appendChild(p);然后document.getElementByID('SignP')不就可以么
document.getElementById是Document对象的方法,用于获取文档对象中的元素,但是你的对象并没有添加到文档中,而只是存在于内存中,所以不可以。