Test possible values for font style - Javascript CSS Style Property

Javascript examples for CSS Style Property:fontStyle

Description

Test possible values for font style

Demo Code

ResultView the demo 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 a 2  s  .c o  m

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

</body>
</html>

Related Tutorials