Get Ul Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Ul

Introduction

The Ul object represents an HTML <ul> element.

You can access a <ul> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<ul id="myUL">
  <li>CSS</li>
  <li>Javascript</li>
  <li>HTML</li>
</ul>//from   w ww.ja  va  2  s. co m

<button onclick="myFunction()">get the id of the unordered list</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myUL").id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials