/    Sign up×
Community /Pin to ProfileBookmark

Simple List id problem

Here is the code

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd“>
<html>
<head>
<title>click</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

<script type=”text/javascript”>

function chekcThis(){
document.getElementById(“show”).innerHTML =” i want to know all the List ‘id’ of Second part Such as ‘karim’,’jasmin'”;
}
</script>

</head>
<body>
First part
<ul id=”first”>
<li id=”sh”>shanto</li>
<li id=”bos”>bos</li>
</ul>
Second Part
<ul id=”second”>
<li id=”karim”>ball</li>
<li id=”jasmin”>pen</li>
</ul>
<br>
<input type=”button” value=”Click Here” onclick=”chekcThis()”>

<div id=”show”>
</div>
</body>
</html>

[B]problem[/B]:I want to know all the <li> ‘id’ of second part.please run the code.and press ‘click here’ for problem details

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mjdamatoJun 18.2007 — &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;click&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;


function chekcThis(elementID){

element = document.getElementById(elementID);

response = "UL-ID: " + element.id + "nLI-IDs:n";
for (i=0; i&lt;element.childNodes.length; i++) {
response += element.childNodes[i].id + "n";
}

alert(response);

}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
First part
&lt;ul id="first"&gt;
&lt;li id="sh"&gt;shanto&lt;/li&gt;
&lt;li id="bos"&gt;bos&lt;/li&gt;
&lt;/ul&gt;
Second Part
&lt;ul id="second"&gt;
&lt;li id="karim"&gt;ball&lt;/li&gt;
&lt;li id="jasmin"&gt;pen&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;input type="button" value="Click Here" onclick="chekcThis('second')"&gt;

&lt;div id="show"&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @shanto 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...