HTML element that mimics another

It sounds crazy, but I'm just wondering if I can have an element (something small or complex) and then have a clone element in another place that mimics absolutely everything that was changed in the first element.

I know that this can be easily achieved using Javascript and jQuery. However, any decisions that I think of are related to the presence of a variable each (or separate instances of elements that change independently)

for example

<div class="class"></div>
<div class="class"></div>
<div class="class"></div>
$('.class').css('color','blue');

This javascript / jQuery piece will select each instance of an element and apply a blue color to each element separately

I want to know if there is a way to change ONE ONE ITEM that will reflect copies of the elements.

Thus, the clone elements will not have their own properties, which can be changed separately. They literally use the properties of the original element. And when the properties of the source elements are changed, as are the clones, because their internal state refers to the source element.

Is there such a design?

My reasoning is this:

If you have 1000 items. Each item is quite large. An element contains things like:

.attributes
.baseURI
.childNodes
.children
.className

etc., and the EACH attribute is COPIED for each item. Is it 1000 copies of .baseURI and .clientWidth? If so. This is very bad.

If an ONE element existed, there would be ONE attributes, .children, etc., and the entire cloned element would use them.

EDIT

Ok, more clarification.

, , , javascript/ajax, , . selectbox, html- , javascript. , , , - , , .

HTML5

+4
2

, :

CSS.

, : .testclass, , test.css, .

css test.css:

.testclass{ background-color: red;}

javascript:

$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'test.css') );

javascript css, , , .testclass.

, .

- -

, . , DOM, , , :

$('your_select_identifier').change(function(e){ //when your select has changed...
  $('the_other_select').remove();//here i removed the old one.
  document.body.appendChild($('your_select_identifier')[0].cloneNode()); //here i cloned the DOM Node of your main select and did append on the document body as the new select.
});

, , , :) ( kkk.)

+1

, .each().

jQuery, .

:

$('.class').each(function() {
  $(this).css('color','blue');
});

.

:

:

$("<style>")
        .prop("type", "text/css")
        .html("\
        .class {\
        color: blue;\
        }")
        .appendTo("head");
0

All Articles