Created
September 20, 2018 08:32
-
-
Save almond-bongbong/0d431fb71fb4ab1fadbfc1fbc8fcc9ca to your computer and use it in GitHub Desktop.
good case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <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'}, | |
]; | |
for (var i = 0; i < a.length; i++) { | |
let item = a[i]; | |
document.getElementById(item.id).onfocus = function(text) { | |
return function() { | |
show(text); | |
}; | |
} (item.text); | |
} | |
} | |
set(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment