Q:

Append a <p> element with a text message using jquery

0

Append a <p> element with a text message when an <input> field is changed using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code:

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>Append a <p> element with a text message when an <input> field is changed</title>
</head>
<body>
<form>
<input id="field1" type="text" value="Field 1">
</form>
</body>
</html>

JavaScript Code :

$( "#field1").change(function() {
  $( "<p>The text has changed.</p>" ).appendTo( "body" );
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now