I have 3 elements:
<h1 class="1" contenteditable="true">ELEMENT</h1>
<h1 class="2">ELEMENT</h1>
<h1 class="3">ELEMENT</h1>
Since the element with class "1" has contenteditable
set to true
, I need to make sure that they all have the same value and update each other while the content is being edited.
For example, if I were to type in FOO, all the other elements would change to be "FOO".
I tried using some JQuery to do this, but I have had no luck.
$(".1").change(function() {
$(".2").text($(this).val());
$(".3").text($(this).val());
});
Any help would be appreciated as I am still new to JQuery and JS.
` does not have value in your example - use `$(this).text()` instead. 3. If script is placed before `
– Regent May 18 '15 at 17:01`, wrap code with `document.ready`. [Fiddle](http://jsfiddle.net/3f5rpzhr/).