Reputation: 215
I am trying to echo the content within a h6 tag, based on:
$('input').keyup( function () {
if ($(this).val() > '0')
$('#testh6').append($(this).parents("tr").clone("h6"));
});
The problem is, that it takes the entire tr not just the containing h6. How can I modify this, so I just clone the h6?
Upvotes: 0
Views: 96
Reputation: 28737
This should do it:
$('input').keyup( function () {
if ($(this).val() > '0')
$('#testh6').append($(this).parents("tr").find("h6").clone());
});
EDIT: Answer to comment:
To remove it again when val == 0
$('input').keyup( function () {
if ($(this).val() > '0') {
$('#testh6 h6').remove(); // Make sure there's no previous tag left.
$('#testh6').append($(this).parents("tr").find("h6").clone());
}
elseif ($(this).val() == '0'){
$('#testh6 h6').remove();
}
});
This will of course remove all h6-tags in that div, if that's not what you want you need to keep a reference or somehow identify it so you can recuperate it later
Upvotes: 1