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:

  Function display (text) {// Text box 'text' $ ('ul' ) .append ('  

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 $ ('

    ') Should use a new & lt; Ul & gt; , while $ ('ul') select the element already present.

    For more information, see

    Then you can rewrite the code like this:

      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

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -