I want to delete the paragraph that jquery create when I click the paragraph.
<p class="test">cutsom event</p>
<button class="clcik">click</button>
jquery:
$(function () {
"use strict";
$(".test").on("click", function () {
$(this).hide();
});
$("button").on("click", function () {
$("<p>delet this paragraph</p>").insertAfter($(this));
});
$("p").on("click", function () {
(this).hide();
});
});
update: @LinkinTED solved it, but dose there best practice for for that code?
deleat this
") $("body").append(p); $(p).click(function(){ $(this).remove(); }) }) – vicky patel Oct 06 '17 at 11:41