Html js problem solution?

  • 0
    Help me find a simple solution to the problem. Just studying html and js, I got stuck.
    Task:
    Create a button when you click on which a picture of an item will appear, the name of which you will write in the input. Choose about 3-4 pictures.
    JavaScript Anonymous, May 30, 2019

  • 3 Answers
  • 0
    When you click on the input, the picture opens, we must make it so that when clicked, the styles switch to the zhs, so that the element is visible, and vice versa, you need to connect to the element using the tree house, and register the event, something like this logic
    Anonymous

  • 0
    It is possible to compare the previously registered variables of the "picture1, picture2" type with the entered text in the input, if the text matches, pressing the button causes the display of the picture under this number.
    Anonymous

  • 0
    <input type="text" id="myinput">
    <input type="button" id="mybutton" value="Взять картинку">


    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('нэээт такой вещ, извини брааат');
    }
    });
    Jace Ryan

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!