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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -