Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36864
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2019-06-11 03:22 -0700 |
| References | <qde3ou$aqm$1@dont-email.me> <9282ef39-13c7-42fc-9436-0a91b52b47e6@googlegroups.com> <XnsAA6AEA097CDC7eejj99@194.109.6.166> |
| Message-ID | <e3286a08-9fbf-4e46-8d06-c5894987f1de@googlegroups.com> (permalink) |
| Subject | Re: Getting the index of a clicked element |
| From | dr.j.r.stockton@gmail.com |
On Monday, 10 June 2019 22:00:31 UTC+1, Evertjan. wrote:
> JRS wrote on 10 Jun 2019 in comp.lang.javascript:
>
> > S.visibility = (S.visibility=="visible" ? "hidden" : "visible")
>
> Parenteses in error!
>
> var S = T.nextSibling.style;
> S.visibility = (S.visibility == "visible") ? "hidden" : "visible";
Neither my parentheses nor yours are needed, at least in current Firefox and Edge. But your "Parenteses" is in error!
As coded, of course, while the answer is toggled between visible and invisible, the space for the answers is permanently visible. If the space is also to be toggled, the OP should use 'display' ("block"/"none", IIRC) instead of 'visibility'.
So, ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test for Q+A problem</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<style type="text/css">
.A { background : lightblue; }
.B { visibility: hidden; background : lightgreen; }
.C { display: none; background : lightgreen; }
</style>
<script>
function F(T) { var S = T.nextSibling.style
S.visibility = S.visibility=="visible" ? "hidden" : "visible"
}
function G(T) { var S = T.nextSibling.style
S.display = S.display=="block" ? "none" : "block"
}
</script>
</head>
<body>
<table summary=Test border=1>
<caption>Click Question to toggle Answer</caption>
<tr><td class=A onclick="F(this)">Q1</td><td class=B>A1</td></tr>
<tr><td class=A onclick="F(this)">Q2</td><td class=B>A2</td></tr>
</table>
<ul style="list-style-type: none;">
<li class=A onclick="F(this)">Q3</li><li class=B>A3</li>
<li class=A onclick="F(this)">Q4</li><li class=B>A4</li>
</ul>
<ul style="list-style-type: none;">
<li class=A onclick="G(this)">Q5</li><li class=C>A5</li>
<li class=A onclick="G(this)">Q6</li><li class=C>A6</li>
</ul>
</body>
</html>
--
(c) John Stockton, near London, UK. Using Google Groups. |
Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |
Back to comp.lang.javascript | Previous | Next — Previous 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