JavaScript Error remove parent using jQuery in Laravel 5

Change from

$(document).on('click', '.delete', function () {
    $(this).parent.parent.remove();
});

to

$(document).on('click', '.delete', function() {
    $(this).parent().remove();
});
Answer:1

Your whole HTML which you are trying to append should be one div. So your code should look like this.

  var tr = '<div class="parent-div"><div class="form-group">' +
               '<label for="title">Title</label>' +
               '<input type="text" class="form-control" name="title[]" value="{{ old('title') }}">' +
               '</div>' +
               '<div class="form-group">' +
               '<label for="body">Body</label>' +
               '<textarea class="form-control" rows="10"  name="body[]" value="{{ old('title') }}"></textarea>' +
               '</div>' +
               '<input type="button" class="btn btn-danger delete" value="x"></div>'; 

And than replace your code with this

$(document).on('click', '.delete', function() {
  $(this).parent().remove();
});
Answer:2

try

$(this).closest("input").remove();
Answer:3

I have created custom tooltip for my chart in chartjs. But the issue comes when I hover on the chart, the tooltip starts flickering. Anyone knows how can I prevent this? Thanks! if (!tooltip) { ...

I have created custom tooltip for my chart in chartjs. But the issue comes when I hover on the chart, the tooltip starts flickering. Anyone knows how can I prevent this? Thanks! if (!tooltip) { ...

Trying to authenticate users on my ionic application through an external service and I need to use cordovas In app browser! The code works perfectly on android however on iOS the "loadstop" event ...

Trying to authenticate users on my ionic application through an external service and I need to use cordovas In app browser! The code works perfectly on android however on iOS the "loadstop" event ...

  1. cordova browser event

There are two conditions: The div (and the divs inside) must have a variable height. The divs inside must add a border on hover over them. There is a problem: The border of the hover adds height to ...

There are two conditions: The div (and the divs inside) must have a variable height. The divs inside must add a border on hover over them. There is a problem: The border of the hover adds height to ...

I'm trying to dynamically populate a ion-select dropdown with a json object. My html component looks like this: <ion-item [hidden]="editOptions.isEditing"> <ion-note stacked color="...

I'm trying to dynamically populate a ion-select dropdown with a json object. My html component looks like this: <ion-item [hidden]="editOptions.isEditing"> <ion-note stacked color="...

  1. ionic populate select
  2. ionic 3 populate select
  3. ionic 2 populate select