Rain Lover
07-23-2014, 07:12 AM
Can you get an attribute default value so you don't have to repeat it in the following example:
<p title="foo" id="p">Hello, world!</p>
<input type="text" id="i">
<script>
var p = document.getElementById('p'),
i = document.getElementById('i');
i.oninput = function () {
p.title = this.value;
if (this.value == 'bar') {
p.title = 'foo';
}
};
</script>
DEMO (http://jsfiddle.net/jU5Tv/)
Is there something like p.title = p.title.defaultValue as we use for text fields?
<p title="foo" id="p">Hello, world!</p>
<input type="text" id="i">
<script>
var p = document.getElementById('p'),
i = document.getElementById('i');
i.oninput = function () {
p.title = this.value;
if (this.value == 'bar') {
p.title = 'foo';
}
};
</script>
DEMO (http://jsfiddle.net/jU5Tv/)
Is there something like p.title = p.title.defaultValue as we use for text fields?