How can get(dynamic) each class fieldset that wrapping the elements in it?
Like:
if click on button adult =get class=> .adult from here in the html: <fieldset class="adult">
if click on button child wbed =get class=> .child wbed from here in the html: <fieldset class="child wbed">
if click on button child bed =get class=> .child bed from here in the html: <fieldset class="child bed">
if click on button baby =get class=> .baby from here in the html: <fieldset class="baby">
Example: http://jsfiddle.net/WErW9/7/
$('button').live("click", function (event) {
event.preventDefault();
$(this).remove();
var $this = $(this),
$div = $this.parent('fieldset');
var name = '.' + $(this).closest('fieldset').attr("class");
alert(name);
});
How about using
closest():[ View output ]