I have a form where I use ajaxSubmitButton to add product items in a HTML table. ajaxSubmitButton helps to use ajax to add item, ajax url take the values and update the table's body `<tr>`, `<td>`. In table, I want to keep a delete button in last column in every rows. When I click the delete button, a row should be deleted. But here delete button does not work. I have checked the hardcoded HTML table and jquery in views that works.

In this circumstance, how could I solve this issue. Please help me. I have given below the form and controller's code:

Form:

```
Yii::app()->clientScript->registerScript('removecartitem', "
$('#remove').click(function(){
$('#cartDetails tr:first').remove();
})
");
?>

<div class="form-group">
    <div class="col-lg-2">
    <?php
    // this is the ajax submit button
    echo CHtml::ajaxSubmitButton('Add Item',Yii::app()->createUrl('admin/order/cart'),
        array(
            'type'=>'POST',
            'update'=>'#cartTable',
        ),
        array('class'=>'btn btn-primary btn-sm',));
    ?>
    </div>        
</div>
<div class="form-group">
    <div class="col-lg-12">
                <table id="cartDetails" class="table table-bordered sortableTable responsive-table">

                    <tbody id="cartTable"> // ajax updates this id 
                    </tbody>
                </table>

    </div>

</div>

```

In controller:

```
public function actionCart()
{
    if(isset($_POST["Order"])){            
    .....
    ..... 
    $cartDetails = Yii::app()->session['cart'];
    if(!empty($cartDetails)){
        foreach($cartDetails as $cart){
            echo '<tr>';
            echo '<td>'.$cart["product_id"].'</td>';
            echo '<td>'.$cart["product_name"].'</td>';
            echo '<td>'.$cart["product_code"].'</td>';
            echo '<td>'.$cart["quantity"].'</td>';
            echo '<td>'.$cart["price"].'</td>';
            echo '<td>'.$cart["totalPrice"].'</td>';
            echo '<td><input type="button" name="add" id="remove" value="Remove" class="btn btn-danger btn-xs"/></td>';
            echo '</tr>';

        }
    }

}

```

At this stage, none of jquery works. Please help how to enable jquery then how to activated the delete button. Please let me know if my explanation is not clear. I have added an images to explain more clear.

![enter image description here](https://i.stack.imgur.com/bI3Mh.png)