/    Sign up×
Community /Pin to ProfileBookmark

show same value as jquery in current multiple div

Hello,
show same value as jquery in current multiple div

“`
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<div id=”elle_iskonto_goster”></div>
<input type=”text” id=”elle_iskonto_goster”>

$( document ).ready(function() {
$(‘#elle_iskonto’).bind(“keyup change”, function(){
var elle_iskonto = $(“#elle_iskonto”).val();
$(“#elle_iskonto_goster”).each(function(){
I also tried this //console.log($(this).html(elle_iskonto));
});
I also tried this //document.getElementById(“elle_iskonto_goster”).innerHTML = elle_iskonto + ” %”;
});
});
“`

How can I show the value I will enter in all divs?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinDec 31.2020 — ``<i>
</i>&lt;h1&gt;The id attribute specifies a unique
id for an HTML element (the value must be
unique within the HTML document).&lt;/h1&gt;
&lt;div id=dsply&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;input type="text" id="elle_iskonto_goster"&gt;
&lt;script&gt;
elle_iskonto_goster.oninput=function(){
dsply.childNodes.forEach(function(item){
if(item.tagName == 'DIV'){
item.innerHTML='';
item.appendChild(document.createTextNode(elle_iskonto_goster.value));
}
});
}
&lt;/script&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@gecekuleauthorDec 31.2020 — Thank you for the answer

I fixed the problem as below

``<i>
</i>var inner = document.querySelectorAll('#elle_iskonto_goster');
for (var i = 0; i &lt; inner.length; i++) {
inner[i].innerHTML = elle_iskonto + " %";
}<i>
</i>
``
Copy linkTweet thisAlerts:
@VITSUSAJan 02.2021 — Nice :)
Copy linkTweet thisAlerts:
@SempervivumJan 02.2021 — Not nice, obviously the TO is still using multiple IDs which is definitely wrong.
×

Success!

Help @gecekule spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...