0

I have the following <-div-> nested

<div id="smallbox">
<ul class="nolist2 formstyle">
<li>
  <div class="span4"><strong>Vehicle Data</strong></div>
</li>
<li>
  <div class="span3"><strong>Coverage<span class="red">*</span></strong></div>
  <div class="span4"><?php echo form_dropdown('coverage',$list_coverage , set_value('coverage', $coverage),'style="width:150px"'); ?></div>
</li>
<li>
  <div class="span3"><strong>Owner<span class="red">*</span></strong></div>
  <div class="span4"><?php echo form_input($owner,'','class="pageRequired" title="Required"'); ?></div>
</li>
</ul>
</div>

this <-div-> block nested will be added if button "ADD_B" push using append and add increment "no" in class

<div class="smallbox1">
:
</div>

I tried to remove the last nested div if button "REMOVE_B" push, but not working using

$("#remove_b").live("click",function () { $("smallbox"+no).remove(); });

with no is the last current number Can anyone help me please.

thanks, frans

Frans
  • 31
  • 2
  • 9

1 Answers1

0

You missed . here $(".smallbox"+no)

$("#remove_b").live("click",function () { $(".smallbox"+no).remove(); });

and live is deprecated use .on

$("#remove_b").on('click', '#remove_b', function() { $(".smallbox"+no).remove(); });
PSR
  • 39,804
  • 41
  • 111
  • 151
  • [`on`](http://api.jquery.com/on) isn't the same thing as [`live`](http://api.jquery.com/on), you can't just swap the names and expect it to work. See the docs for how to handle delegated events with `on` – nbrooks Mar 22 '13 at 05:40
  • How you're doing it currently is for direct events. `live` is for delegated events. You have to do something like `$(document).on('click', '#remove_b', function() { })`. Please, read the docs. – nbrooks Mar 22 '13 at 05:52
  • hi all, i still don't get the solution, which doc specifically should i read? I've managed to trap the click event, but the remove process is still not working – Frans Mar 23 '13 at 05:58