Last active
December 14, 2017 14:00
-
-
Save pastyrMisha/4d6a07e2e527177cea181622a4ad6a43 to your computer and use it in GitHub Desktop.
форма комментариев с эмуляцией обработки
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="comments"> | |
<p>Комментарий №1</p> | |
<p>Комментарий №2</p> | |
<p>Комментарий №3</p> | |
</div> | |
<form name="form" action="#" method="post" id="form" style="display:none" onsubmit="return false" /> | |
<textarea id="textarea" name="comment" cols="30" rows="10"></textarea> | |
<input type="submit" name="send" value="Добавить комментарий" id="done" /> | |
</form> | |
<a href="#" onclick="return false" id="add_comment">Добавить комментарий</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function() { | |
$(document).on("click", "#add_comment", function () { | |
var form = $("form[name='form']"); | |
form.css("display", "block"); | |
$("#add_comment").replaceWith(form); | |
}); | |
$(document).on("click", "input[name='send']", function () { | |
var comment = $("textarea[name='comment']").val(); | |
alert("Подождите идётзагрузка комментариев..."); | |
$("<p>" + comment + "</p>").appendTo("#comments"); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment