Tom Cruise
Tom Cruise

Reputation: 1415

jQuery - how to access jQuery object?

I'm struggling to find out when to use #,$ in jquery. i.e. if I have an object

var elem{
}

How to access this? Whether $('#elem') or $('elem')? May be its too silly. But I cant find out a solution by googling it.

Upvotes: 0

Views: 166

Answers (1)

jabclab
jabclab

Reputation: 15042

It looks to me like how to you've used .appendTo(). You need to pass an ID in your case, I believe; something like:

$("<table>").attr("id","waiterBlock").appendTo("testDiv");

Changed to:

$("<table>").attr("id","waiterBlock").appendTo("#testDiv");

The documentation for jQuery's .appendTo() says one needs to pass:

A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter.

Upvotes: 1

Related Questions