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

1 Answer

0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
 
<span></span>
<br />
<span></span>
<script>
$( "span:first" ).text("abc - first");
$( "span:last" ).text("xyz - last");

/*
run:

abc - first
xyz - last

*/

</script>
</body>
</html>

 



answered Aug 19, 2016 by avibootz
...