Can you update the shortcut using javascript?

I have a javascript function that I am trying to update. If I replace the label with a text box, it works fine, but nothing happens with the label!

Shortcut example:

<label id="163" name="163">Some text.</label>

Javascript code:

$("#163").val("meep");
+3
source share
4 answers

The method valsets the value of the input element. This will not affect other elements, including<label>

You need to call a method textthat sets the text of any element.

For instance:

$("#163").text("meep");
+5
source

<label> , "". , . text(str):

$("#163").text("meep");
+5

Try the text method:

$("#163").text("meep");
+2
source

In addition, IDand NAMEattributes must not start with a number, although in most cases it will not actually cause problems.

+2
source

Source: https://habr.com/ru/post/1728363/


All Articles