How to use jQuery .text() to write text to <p> HTML tag

3 Answers

0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>

<p></p>
<script>
 $( "p" ).text("Hi")
</script>
</body>
</html>

 



answered Aug 23, 2016 by avibootz
0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>

<p></p>
<p></p>
<script>
 $( "p:first" ).text("text 1")
 $( "p:last" ).text("text 2")  
</script>
</body>
</html>

 



answered Aug 23, 2016 by avibootz
0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>

<p></p>
<p></p>
<script>
 $( "p:first" ).text("text 1")
 $( "p:last" ).text($( "p:first" ).text())  
</script>
</body>
</html>

 



answered Aug 23, 2016 by avibootz
...