How to select the id of the first div inside the div jQuery -
i have <div>
<div id="category_choice"></div>
when category item <div>
clicked on, .appends
<div id="sports" class="category_item" onclick="addcategory('sports/health')"> <div id="sports_thumb" class="category_thumb"></div> <p>sports/health</p> </div>
inside of it. now, when click submit button, has pass id of "category_item" inside "category_choice" ajax.
i have tried following code:
$(document).on('click','#nsubmit', function () { var category = $('#category_choice:first-child').attr('id');
ajax... bla-bla-bla data: category: category... along other data haven't mentioned, because sends fine. "category" remains empty. please tell me mistake.
may space??
$("#category_choice :first-child").attr('id')
or
as @david mentioned in comment
$('#category_choice > :first')
Comments
Post a Comment