chang
chang

Reputation: 9

how to get id of next div using previous id using jquery

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

Answers (1)

adeneo
adeneo

Reputation: 318182

That's not the next element, it's the first child

var y = $('#sms_message-0').children().first().attr('id');

Upvotes: 1

Related Questions