Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40387
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: changing the value of a text box with .js |
| Date | 2021-09-17 00:46 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <5497567.DvuYhMxLoT@PointedEars.de> (permalink) |
| References | <sh31k5$167f$1@gioia.aioe.org> <slrnsjai2s.78u.jon+usenet@raven.unequivocal.eu> <tx928w8dphta$.1jplgn5qs6ioi.dlg@40tude.net> |
JJ wrote:
> On Sun, 5 Sep 2021 22:44:44 -0000 (UTC), Jon Ribbens wrote:
>> On 2021-09-05, bill <william@TechServSys.com> wrote:
>>> I know how to change the value of a span or div using:
>>> onClick= document.getElementById("searchkey").value = "type min 3
>>> letters";
“span” or “div” elements do not have a built-in “value” property.
>>> but that does not work for an input type=text element.
*That* should work, though, as the corresponding object *does* have a built-
in value property.
>>> What is the proper way to do that?
>>
>> Did you mean that the other way around? If so you might want the
>> 'textContent' property.
>
> And make sure correct quoting is used. Use HTML entity and escape sequence
> if necessary.
>
> Cause, the provided sample code will never work, regardless of what HTML
> tag/element it is on.
By contrast to the “innerHTML” property, the “textContent” property does not
require any escaping beyond the one required for a syntactically correct
ECMAScript program; indeed, if you HTML-escape the value assigned to it, the
escape sequences will be displayed verbatim.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
changing the value of a text box with .js bill <william@TechServSys.com> - 2021-09-05 14:17 -0400
Re: changing the value of a text box with .js Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-09-05 22:44 +0000
Re: changing the value of a text box with .js JJ <jj4public@gmail.com> - 2021-09-06 14:39 +0700
Re: changing the value of a text box with .js Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-09-17 00:46 +0200
Re: changing the value of a text box with .js Arno Welzel <usenet@arnowelzel.de> - 2021-09-06 15:09 +0200
csiph-web