/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Text, expand

Hi,
Scenario:
I have a [a href] for each player in a html, and i want to expand the player
info when they click on the playername.
Under the playername i want dynamic show more detail, example age, weight…
And if the click on the playername again i want to reset to one line with
only playername.

How can the script look like for this?

Help

Thanx
Zpecialz

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 05.2005 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>show - hide</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
<!--
onload=function() {
var h3List=document.getElementsByTagName('h3');
var ulList=document.getElementsByTagName('ul');
for(var i=0; i<ulList.length; i++) {
h3List[i].style.cursor='pointer';
h3List[i].onclick=function() {toggle(this);}
ulList[i].style.display='none';
}
}

function toggle(obj) {
var sibling;
if(obj.nextSibling.nodeType==3) {
sibling=obj.nextSibling.nextSibling;
}
else {
sibling=obj.nextSibling;
}
sibling.style.display=(sibling.style.display=='block')? 'none' : 'block';
}
//-->
</script>
</head>
<body>
<h3>player 1</h3>
<ul>
<li>age:</li>
<li>weight:</li>
</ul>
<h3>player 2</h3>
<ul>
<li>age:</li>
<li>weight:</li>
</ul>
<h3>player 3</h3>
<ul>
<li>age:</li>
<li>weight:</li>
</ul>
</body>
</html>
Copy linkTweet thisAlerts:
@zpecialauthorMay 05.2005 — Hi again,

Thanx for the code, it works fine on internet.

That i didnt say in the earlier message, i will run this code on xhtml 1.0.

Browser in mobile.

Must i use DOM for do that, or is it impossible to do dynamic text for browser in mobile.

/ zpecial
Copy linkTweet thisAlerts:
@FangMay 05.2005 — Try it
Copy linkTweet thisAlerts:
@zpecialauthorMay 05.2005 — it didnt work.
Copy linkTweet thisAlerts:
@zpecialauthorMay 05.2005 — hide and show didnt work, only show all the time
Copy linkTweet thisAlerts:
@FangMay 05.2005 — Does the mobile support JavaScript?
Copy linkTweet thisAlerts:
@SonikAMDMay 06.2005 — javascript's not supported on mobiles yet.
Copy linkTweet thisAlerts:
@zpecialauthorMay 06.2005 — Is there anyway to do it dynamic with expand text in mobile?

Script or DOM?
×

Success!

Help @zpecial spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...