# Methods and properties chaining in JavaScript

Let us have an input:

`<input id="elem" value="text">`

Let's display the input text:

`let elem = document.querySelector('#elem'); console.log(elem.value); // shows 'text'`

As you can see, we first get an element by its `id`, write this element to the variable `elem`, and then display the property `value` from this variable

In fact, you can not enter the variable `elem`, but build a chain of dots in this way:

`console.log( document.querySelector('#elem').value ); // shows 'text'`

In the same way - in a chain - you can overwrite attributes:

`document.querySelector('#elem').value = 'www';`

Given the following code:

`<img id="image" src="avatar.png">` `let image = document.querySelector('#image'); console.log(image.src);`

Modify the code above to use a chain instead of introducing the variable `image`.

←→
↑
en ru