The code below works, but I suspect there is be a cleaner.
Any alternative to reference the selector names, specially the first differently?
jQuery
$(".add_one_more").click(function(){
var themsg = $(this).parent().attr('id');
$('"#'+themsg+'"').stop().fadeOut("slow",function(){
$("#entry_area").stop().fadeIn("slow");
});
return false;
});
HTML
<div id="entry_area">Form Goes Here</div>
<div id="msg0">
<span style="font-size: 130%; color: green;">One Message</span>
<a href="" class="add_one_more">Try Again</a>
</div>
<div id="msg1" style="width: 550px;">
<span style="font-size: 130%; color: red;">Another Message</span>
<a href="" class="add_one_more">Try Again</a>
</div>
You shouldn’t need to select the parent and get its ID.