btn=$(".bx-composite-btn")//выбрал кнопку $(".footer li:last-child").after('<li>'+btn+'</li>')//вставил кнопку //получил <li>1</li> <li>2</li> <li>[object Object]</li>//получаю <li><a class="bx-composite-btn">текст</a></li>//а должно быть 
  • This is all because btn is an object, not a string, and when casting to a string, "[object Object]" is obtained - Grundy
  • @Grundy how to fix? - test_q_1
  • one
    Obviously - not to insert an object, but to insert lines - Grundy

1 answer 1

This is all because btn is an object, not a string, and when casting to a string, you get "[object Object]"

To solve, you can use the possibility of creating objects, rather than collecting the string, for this you need to change the insertion code

 btn=$(".bx-composite-btn")//выбрал кнопку $(".footer li:last-child").after($('<li>').append(btn))//вставил кнопку 

In this case, the button will be transferred to the last li