How to get and set HTML element value by tag name with jQuery

1 Answer

0 votes
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>

<p>Text text text</p>

<p id="p_id"></p>

<script>
$(document).ready(function() {
  var pp = $("p"); // get
  $("#p_id").text("p_id: " + pp[0].innerHTML); // set
});
</script>

</body>
</html>

<!--
run:

Text text text

p_new: Text text text

-->

 



answered Jan 10, 2019 by avibootz
...