Add before

Description

The following code shows how to add before an element.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type='text/javascript'>
  $(document).ready(<!--from www  . ja va  2  s.  co m-->
      function() {
        $('p').before("<h4>Quotes</h4>").after(
            "<p class='tmpAttribution'>- after</p>\n");
      });
</script>
<style type='text/css'>
p {
  margin: 5px;
}

p.tmpAttribution {
  text-align: right;
}
</style>
</head>
<body>
  <p>java2s.com</p>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities