Reputation: 351
I feel uncomfortable having to create elements scattered everywhere and change them one by one when variable is changed.
<div>
<div class="element-1"></div>
<div class="element-2"></div>
</div>
<script>
var e1= "";
var e2= "";
SomeEvent.trigger(function(){
e1= "this is content of element-1";
e2= "this is content of element-2";
});
$("value of e1").change(function(){
$(".element-1").html(e1);
});
$("value of e2").change(function(){
$(".element-2").html(e2);
});
</script>
Can I do something like it only with js
or jQuery
?
<div>
{{e1}}
{{e2}}
{{e3}}
</div>
And {{e?}}
is binding with e?
. It show e?
's value and change everywhere e?
changes. Thanks.
Upvotes: 0
Views: 55