Reputation: 9
I want to get id of next element using jquery
. HTML code is is follow.
<div id="sms_message-0"><div id="nl-form-0" class="nl-form"></div>
I have tried this,
y= $('#sms_message-0').next().find('div').attr("id");
console.log(y);
Here nl-form-0
is dynamic . so i want to get it's id using static id sms_message-0
.
Upvotes: 1
Views: 52
Reputation: 318182
That's not the next element, it's the first child
var y = $('#sms_message-0').children().first().attr('id');
Upvotes: 1