Reader small image

You're reading from  JavaScript from Frontend to Backend

Product typeBook
Published inJul 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781801070317
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Eric Sarrion
Eric Sarrion
author image
Eric Sarrion

Eric Sarrion is a trainer and a developer as an independent consultant. He has been involved in all kinds of IT projects for over 30 years. He is also a long time author in web development technologies and is renowned for the clarity of his explanations and examples.
Read more about Eric Sarrion

Right arrow

Modifying an element in the list

Modifying a list element is done in several steps:

  1. Following a click on the Modify button, we transform the text of the list element (currently a <span> element) into an HTML <input> element initialized with the text of the element.
  2. Then we manage the exit of the input field, by retrieving the value entered in the field, then by replacing the input field with a <span> element with the new content.
  3. Finally, we improve the input by allowing the input control to automatically have the focus after clicking on the Modify button.

Let’s see these different steps in depth.

Transforming the <span> element into an <input> element

The first step is to transform the <span> element into an <input> element, which will allow the text of the element to be modified. To do this, we will add a new reactive variable (named "input") in the <Element> component. It indicates whether...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
JavaScript from Frontend to Backend
Published in: Jul 2022Publisher: PacktISBN-13: 9781801070317

Author (1)

author image
Eric Sarrion

Eric Sarrion is a trainer and a developer as an independent consultant. He has been involved in all kinds of IT projects for over 30 years. He is also a long time author in web development technologies and is renowned for the clarity of his explanations and examples.
Read more about Eric Sarrion