I
I
i_want_to_know_everything2015-10-28 08:06:10
JavaScript
i_want_to_know_everything, 2015-10-28 08:06:10

Cloning an element and the next one after it?

target = $(this).clone().wrap('<p>').parent();
that's how it works;

target = $(this).clone().wrap('<p>').parent() + $(this).next().clone().wrap('ul').parent();

So no returns [object Object][object Object] with an error
Syntax error, unrecognized expression: [object Object][object Object]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Serdji, 2015-10-28
@i_want_to_know_everything

It gives a correct error, because it will not work to concatenate two objects. If you want to take only the text from these objects and concatenate it, you will most likely need 3 variables.

var per1 = $(this).clone().wrap('<p>').parent().text(),
      per2 = $(this).next().clone().wrap('ul').parent()text(),
      target = per1 + per2;

If you are trying to add the numbers in these objects, then they are initially set to strong, and they need to be cast to the value of namber like this
var per1 = $(this).clone().wrap('<p>').parent().text(),
      per2 = $(this).next().clone().wrap('ul').parent()text(),
      target = Namber(per1) + Namber(per2);

S
Sergey Voronkov, 2015-10-28
@no_smoking

Maybe this suits you
var target = $(this).clone().wrap('').parent().add($(this).next().clone().wrap('ul').parent( ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question