Skip to main content

Bug Tracker

Side navigation

#9852 closed bug (invalid)

Opened July 18, 2011 05:38AM UTC

Closed July 18, 2011 01:43PM UTC

about DOM

Reported by: zhou695105338@sina.com Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

I want to use jquery to complete autocomplete function , but I found some problem about DOM.Here is the code

if($("#ul_autocomplete")[0])
     $("body").remove($("#ul_autocomplete"));
						
var down = $("<ul style='position:absolute;list-style:none;border:1px solid;background-color:white;margin:0;padding:0;z-index:100;padding-bottom:15px;'></ul>");	

down.css({width:input.outerWidth(),height:input.height()*items.length,left:position.left,top:position.top+input.outerHeight()});	

down.attr("id","ul_autocomplete");

down.appendTo($(document.body));

This code will be execute only once.The next time it will stop on code "$("body").remove($("#ul_autocomplete"));" (I see this in firebug)

But if I use javascript like this

if(document.getElementById("ul_autocomplete"))
	document.body.removeChild(document.getElementById("ul_autocomplete"));

The code work fine

Attachments (0)
Change History (1)

Changed July 18, 2011 01:43PM UTC by timmywil comment:1

component: unfiledmanipulation
priority: undecidedlow
resolution: → invalid
status: newclosed

I'm not sure what that code would do, but it is not the correct usage of remove. I'd try

$('#ul_autocomplete').remove();