Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39207

Re: Accessing DIV value on current document

From Jake Jarvis <pig_in_shoes@yahoo.com>
Newsgroups comp.lang.javascript
Subject Re: Accessing DIV value on current document
Date 2020-11-27 13:55 +0100
Organization A noiseless patient Spider
Message-ID <rpqt09$3l0$1@dont-email.me> (permalink)
References <0af79463-50bf-47e3-9e64-16639ec109edn@googlegroups.com> <querySelector-20201127133538@ram.dialup.fu-berlin.de>

Show all headers | View raw


Am 27.11.2020 um 13:37 schrieb Stefan Ram:
> Tatsujin <tatsujin.3.r@gmail.com> writes:
>> <div class="outerbox">
>>   <div class="c1">Some words here</div>
>>   <div class="c2">More words here</div>
>> </div>
>> How do I access (or get a reference to) the text value in DIV class "C2"?
>> I thought maybe it was "document.c2.value", but I was wrong.
> 
>    I'd suggest to add an id to it and then use »getElementById«.
> 
>    Otherwise, something like
> 
> document.getElementsByClassName( "c2" )[ 0 ]
> 
>    or
> 
> document.querySelector( "div.outerbox > div.c2" )
> 
>    might work, depending on what else is contained in that document.
> 
> 

Tatsujin:
now that you got the element, read its textContent property

https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Accessing DIV value on current document Tatsujin <tatsujin.3.r@gmail.com> - 2020-11-26 23:42 -0800
  Re: Accessing DIV value on current document "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-11-27 13:49 +0100
    Re: Accessing DIV value on current document Jake Jarvis <pig_in_shoes@yahoo.com> - 2020-11-27 14:02 +0100
      Re: Accessing DIV value on current document Tatsujin <tatsujin.3.r@gmail.com> - 2020-11-27 11:19 -0800
  Re: Accessing DIV value on current document Jake Jarvis <pig_in_shoes@yahoo.com> - 2020-11-27 13:55 +0100

csiph-web