If you're going to work with jQuery then all you need to know
(assuming you know HTML and CSS, and have a general understanding of
JavaScript) is contained in the docs.

var list = document.createElement("li");  uses a DOM method (not
jQuery). The variable 'list' is a DOM node, a way to add text to it is
to use other DOM methods, e.g.:

var list = document.createElement("li");
list.appendChild(document.createTextNode('hello'));
document.getElementsByTagName('ul')[0].appendChild(list);

There are a number of resources on the web for explaining DOM
manipulation (here's one https://developer.mozilla.org/en/Gecko_DOM_Reference)

You can mix the DOM methods with jQuery if you like (in some cases
they're faster). You'll also find that there are many 'jQuery' ways to
achieve the same end. Some are faster or easier to maintain, you'll
have to decide what works for you. As an example, James' jQuery code
could be written like this:

var list = $('<li>').text('hello world').appendTo('#myUL');



On Feb 26, 6:36 pm, James <james.gp....@gmail.com> wrote:
> var list = $("<li>some text</li>");
> list.text('hello world');  // 'some text' is changed to 'hello world'
> $("#myUL").append(list);   // puts the element into your #myUL <ul> in
> your html document.
>
> On Feb 26, 3:53 pm, Sonya <ayson...@googlemail.com> wrote:
>
> > Hello,
>
> > I just begin to work with jQuery and have some questions. Where I can
> > find a list of all properties for elements. E.g. I generate a list
> > item:
> > var list = document.createElement("li");
>
> > How can I fill in in the list? list.text doesn't work. I have to guess
> > again and again for each element which properties it has. Is there an
> > API where I can see all properties of the object?
>
> > Thank you,
> > Sonya

Reply via email to