almost 9 years ago
append( ) property is used to insert a block of elements inside a particular element. It helps in adding block of element during runtime.This property insert's content, specified by the parameter, to the end of each element in the set of matched elements.
<!DOCTYPE html>
<html>
<head>
<title>append() property</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p><button type="button">add more settings</button></p>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
alert('asdf');
$("body p").append('<div><label>enter phone no.</label><input type="text"></div>');/*it adds block of element inside <p> tag*/
});
});
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<title>append() property</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p><button type="button">add more settings</button></p>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
alert('asdf');
$("body p").append('<div><label>enter phone no.</label><input type="text"></div>');/*it adds block of element inside <p> tag*/
});
});
</script>
</html>
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)