How to capture a jquery element and leave changed in a new variable without changing the view?

2

For example, I want to get the DOM element, and then change, without it changing the behavior in the view:

//aqui pego o conteúdo da html
var content = $('.content').get(0);
//aqui eu reescrevo, porém ocorre que o $('.content') também está sendo alterado...???
 var new_content = $(content).removeClass('ql-align-justify');

I want only the variable to be modified.

    
asked by anonymous 05.06.2017 / 21:43

1 answer

1

You can create a clone, which generates an identical element but only contained in the variable. You can then change it and then put it in the DOM / View when needed.

var content = $('.content').clone().get();
$(content).removeClass('ql-align-justify');
// e mais tarde 
$(body).append(content);
    
05.06.2017 / 22:49