Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36823
| From | James Harris <james.harris.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Getting the index of a clicked element |
| Date | 2019-06-07 17:59 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <qde54s$j9q$1@dont-email.me> (permalink) |
| References | <qde3ou$aqm$1@dont-email.me> |
On 07/06/2019 17:35, James Harris wrote: > Almost a complete beginner at JavaScript so there may be a better way to > do this but ... what I am trying to do is have a web page consisting of > pairs of questions and answers as in > > Question > Answer > Question > Answer > Question > Answer > > where clicking on the question toggles whether the answer appears or > not. Answers will initially be absent. So the above would initially appear as Question Question Question and users would have to click on a question to reveal the subsequent answer. > > I've got that bit worked out in a way I like (will explain in a separate > post). To explain the rationale behind the choices: First, I want, for convenience, to be able to type the answers in directly under the questions to which they correspond. Since the page is intended to begin with the answers hidden that meant having them present but hiding them on page load. Second, I don't want the way to hide the text to be by making it invisible (e.g. by setting a CSS property) as I fear that could end up with the browser's 'find' function irritating the user by finding text the user cannot see. That's why I decided to move the InnerHTML of the answers to and from an array. Third, I want this to be compatible with many browsers and generations of browser so didn't want to use the data- features which I've heard are part of the 'ultra modern' HTML5. :-) Fourth, I want the web page to be usable even if the browser does not have JavaScript enabled. In that case, all answers would have to be visible all the time. Again, that meant the page having the answers there by default and using JavaScript, if enabled, to hide the answers on page load. That's my rationale for the basic approach. As I say, next thing is how to know which answer to toggle when a certain question is clicked. I guess this is well-trodden ground but I was evidently using the wrong keywords for Google to magic up an answer. Hence this query. -- James Harris
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-07 17:35 +0100
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-07 17:59 +0100
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-07 20:33 +0200
Re: Getting the index of a clicked element dr.j.r.stockton@gmail.com - 2019-06-08 01:43 -0700
Re: Getting the index of a clicked element "R.Wieser" <address@not.available> - 2019-06-07 19:39 +0200
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-08 18:52 +0100
Re: Getting the index of a clicked element Julio Di Egidio <julio@diegidio.name> - 2019-06-07 10:45 -0700
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-08 18:57 +0100
Re: Getting the index of a clicked element Julio Di Egidio <julio@diegidio.name> - 2019-06-09 05:44 -0700
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-07 20:16 +0200
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-07 22:48 +0200
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-07 20:36 +0200
Re: Getting the index of a clicked element JJ <jj4public@vfemail.net> - 2019-06-08 12:57 +0700
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-08 10:30 +0100
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-08 12:13 +0200
Re: Getting the index of a clicked element John G Harris <niam@jghnorth.org.uk.invalid> - 2019-06-08 13:35 +0100
Re: Getting the index of a clicked element John G Harris <niam@jghnorth.org.uk.invalid> - 2019-06-08 13:45 +0100
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-08 19:03 +0100
Re: Getting the index of a clicked element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-08 21:11 +0200
Re: Getting the index of a clicked element dr.j.r.stockton@gmail.com - 2019-06-08 14:18 -0700
Re: Getting the index of a clicked element dr.j.r.stockton@gmail.com - 2019-06-08 02:16 -0700
Re: Getting the index of a clicked element James Harris <james.harris.1@gmail.com> - 2019-06-08 19:14 +0100
Re: Getting the index of a clicked element dr.j.r.stockton@gmail.com - 2019-06-10 11:29 -0700
Re: Getting the index of a clicked element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-06-10 23:00 +0200
Re: Getting the index of a clicked element dr.j.r.stockton@gmail.com - 2019-06-11 03:22 -0700
csiph-web