Would appending to a non existing element create a new instance of that element in JQuery? -
In my browser, I have a textbox and a submit button, using text from the textbox, At the end of the anodized list, I want to add as a list item. The unstarred list is not present yet, but I want to present the text under the text box and submit the button. I created this function:
Code: When I use .display (), I want to be able to display the text in the parameter as a new list item in an unordered list. Question: Does JQuery make a new 'ul' if someone is not in existence yet or should I make one first? If so, am I using JQuery correctly to add a list item to the unordered list? Any advice helps! Thanks! First you For more information, see Then you can rewrite the code like this:
Function display (text) {// Text box 'text' $ ('ul' ) .append ('
$ ('
') Should use a new
& lt; Ul & gt; , while
$ ('ul') select the element already present.
var ul = $ ('& Lt; ul & gt; '); // Save the newly created element Ul.appendTo ('body') // it & lt; Body & gt; Add or add other text to the text display (text) {// 'text' text box. Append ('
Comments
Post a Comment