Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <input type="text" id="myinput">
  <input type="button" id="mybutton" value="Взять картинку">
</body>
</html>
 
let things = {
  'ручка' : 'http://site.ru/ruchka.jpg',
  'карандаш': 'http://site.ru/karandash.jpg',
  'ластик': 'http://site.ru/lastik.jpg'
}
document.getElementById('mybutton').addEventListener('click',()=>{
   let val = document.getElementById('myinput').value.toLowerCase().trim();
   if(val in things){
      let img = document.createElement('img');
      img.src = things[val];
      document.body.appendChild(img);
   } else {
      alert('нэээт такой вещ!');
   }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers