Javascript DOM HTML Paragraph Object set title

Introduction

Change the title of a <p> element:

document.getElementById("myP").title = "The Development Site";

Click the button to change the title of the p element below.

Hover over the 'java2s.com' text before and after you click the button.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="myP" title="this is a description">java2s.com</p>

<button onclick="myFunction()">Test</button>
<script>
function myFunction() {/*w  w w .j  ava2s . com*/
  document.getElementById("myP").title = "The Development Site";
}
</script>

</body>
</html>



PreviousNext

Related