Reputation: 4187
I am trying to get the jquery equvaliant of this javascript
var id = $(this).parent().parent().parent().attr("id");
document.getElementById(id).getElementsByClassName("addcomment")[0].style.display = 'block';
but its not working
$('#+id+' '.addcomment').css('display','block');
Any suggestions ?
Upvotes: 1
Views: 356
Reputation: 11
I think you need to get the child elements based on their class. So try this.
$('#' + id ).find('.addcomment').show();
Upvotes: 1
Reputation: 123377
$('#' + id + '.addcomment').css('display','block');
as a sidenote in the page you should have only one element with that id, so
$('#' + id ).css('display','block');
should works too (of course only if classname it's not necessary to target it, since this is a different selector)
Upvotes: 4
Reputation: 87073
$('.addcomment', '#' + id).css('display','block');
or just simple
$('#' + id).css('display','block');
Upvotes: 1