Spread the love


If you are dealing with tables or any other HTML element using jQuery you may want to implement a multilevel append function. And you want the low-level append to be dynamic data. Then how to add a loop inside jQuery’s append function?

Add loop inside jQuery append method.

Simply, You can’t add a loop inside append function! ๐Ÿ™

But there is a way to do it ๐Ÿ™‚ First, declare a string variable and concatenate everything you want to be appended. then use that string as part of the appended content. Here is a simple example.

//#weekDays:we want to loop this array
var weekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
      $.each(weekDays, function (index, row) {
         var $dataToBeAppended += `<tr><td>${row}</td></tr>`;
     });
$("#tbody").append($dataToBeAppended);

ย 

Read More

Beautifull React Quantity Picker

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *