I have the following elements:
<p class="id-task">5</p>
<p class="status-change">
<i id="test-task" class="fa fa-flask fa-lg" aria-hidden="true"></i>
</p>
I'm trying to get the number of <p class="id-task">5</p>
with the following Jquery code:
$('#test-task').on('click', function(){
var father = $(this).parent().siblings();
var idTask = $(father).text();
alert(idTask);
});
I changed the code, because the parent()
end has to be .siblings()
, because <p class="id-task">5</p>
is brother of <p class="status-change"></p>