Skip to content

Instantly share code, notes, and snippets.

@almond-bongbong
Created September 20, 2018 08:03
Show Gist options
  • Save almond-bongbong/dfe78fdb5d81041d966ea9fbc4874942 to your computer and use it in GitHub Desktop.
Save almond-bongbong/dfe78fdb5d81041d966ea9fbc4874942 to your computer and use it in GitHub Desktop.
good case , ie9 <=
// <input type="text" id="email">
// <input type="text" id="name">
// <input type="text" id="phone">
// <div id="notice"></div>
function show(text) {
document.getElementById('notice').innerHTML = text;
}
function set() {
var a = [
{id: 'email', text: 'email'},
{id: 'name', text: 'name'},
{id: 'phone', text: 'phone'},
];
a.forEach(function(item) {
document.getElementById(item.id).onfocus = function() {
show(item.text);
}
});
}
set();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment