Use prepend() method to insert the text "Hello" at the beginning of the <p> element. - Javascript jQuery

Javascript examples for jQuery:Tag Edit

Description

Use prepend() method to insert the text "Hello" at the beginning of the <p> element.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").prepend("Hello");
});/* w ww  .  j  av a  2 s.  co m*/
</script>
</head>
<body>

<p> World!</p>

</body>
</html>

Related Tutorials