By clicking on the "mylink" I want the link to be replaced by the number "123", which is extracted from parent tag. I think I m not doing the ".match(...." right.
jQuery:
$(document).ready(function(){
$(".link").click(function(){
var comid = $(this).parents("div.comment").attr("class").match(/comment-([0-9]+)/)[1];
$(".link").replaceWith(comid);
});
});
html:
<div class="comment comment-123 ct">
<div class="link">mylink</div>
</div>