Javascript DOM CSS Style fontStyle Property for possible values

Introduction

A demonstration of possible values for fontStyle Property:

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP">This is a paragraph.</p>

<select onchange="myFunction(this);" size="3">
  <option>normal</option>
  <option>italic</option>
  <option>oblique</option>
</select>//from w w w.  j  a  v  a2s. co  m

<script>
function myFunction(selectTag) {
  var listValue = selectTag.options[selectTag.selectedIndex].text;
  document.getElementById("myP").style.fontStyle = listValue;
}
</script>

</body>
</html>



PreviousNext

Related