jQuery <h1> add multiple classes

Description

jQuery <h1> add multiple classes

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Adding multiple Classes to the Elements in jQuery</title>
<style>
    .page-header{/*from   w  w w  .j  a  v a 2 s  . c  om*/
        color: red;
        text-transform: uppercase;
    }
    .highlight{
        background: yellow;
    }
  .hint{
        font-style: italic;
    }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("h1").addClass("page-header highlight");
    });
});
</script>
</head>
<body>
    <h1>Hello World</h1>
    <p>The quick brown fox jumps over the lazy dog.</p>
    <button type="button">Add Class</button>
</body>
</html>



PreviousNext

Related