jquery - Accessing very nested element directly by referring main Parent class -


i working on chrome extension. have following html belongs facebook. goal fetch latests posts. can fetch posts looking class name timelineunitcontainer

<div class="timelineunitcontainer" id="u_jsonp_2_3" data-gt="{"eventtime":"1396797532","viewerid":"100000804868370","profileownerid":"100000804868370","unitimpressionid":"f5511fc8","contentid":"3298878988034773094","timeline_unit_type":"statusmessageunit","timewindowsize":"3","query_type":"36","contextwindowstart":"0","contextwindowend":"1398927599"}" data-time="1396685690"> <div class="">    <div role="article">       <div class="clearfix mbs pbs _1_m">          <a class="_29h _303 _51wa" href="https://www.facebook.com/sid.labs?hc_location=timeline" data-ft="{"tn":"\u003c"}" tabindex="0" aria-hidden="true" data-hovercard="/ajax/hovercard/user.php?id=100000804868370&amp;extragetparams=%7b%22hc_location%22%3a%22timeline%22%7d" aria-owns="js_4" aria-haspopup="true" id="js_6"><img class="_s0 _50c7 _54rt img" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t1.0-1/c4.4.48.48/p56x56/1010859_539620286074795_1558724572_s.jpg" alt=""></a>          <div class="_3dp _29k">             <h5 class="_1_s" data-ft="{"tn":"c"}"><span class="fcg"><span class="fwb" data-ft="{"tn":";"}"><a href="https://www.facebook.com/sid.labs?hc_location=timeline" data-hovercard="/ajax/hovercard/user.php?id=100000804868370&amp;extragetparams=%7b%22hc_location%22%3a%22timeline%22%7d">jhon doe</a></span></span> </h5>             <div class="_1_n fsm fwn fcg">                <a class="uilinksubtle" href="/xx/posts/644752595561563?stream_ref=10"><abbr title="saturday, april 5, 2014 @ 1:44pm" data-utime="1396730690">yesterday</abbr></a> near <a class="uilinksubtle" href="https://www.facebook.com/pages/karachi-pakistan/110713778953693?ref=stream">karachi</a>                <div class="uiselector inlineblock audienceselector timelineaudienceselector audienceselectornotruncate dynamiciconselector uiselectornormal uiselectordynamictooltip">                   <div class="uitoggle wrap"><a data-hover="tooltip" aria-label="public" data-tooltip-alignh="center" class="uiselectorbutton uibutton uibuttonsuppressed uibuttonnotext" href="#" role="button" aria-haspopup="1" aria-expanded="false" ajaxify="/ajax/privacy/privacy_menu.php?iconsize=small&amp;oid=644752595561563" data-oid="644752595561563" data-label="" data-length="30" data-tooltip="public" rel="toggle" id="js_7"><i class="mrs defaulticon customimg img sp_5l8dti sx_d52e6e"></i><span class="uibuttontext"></span></a></div>                </div>             </div>          </div>       </div>       <div class="_1x1">          <div class="usercontentwrapper">             <div class="_wk"><span data-ft="{"tn":"k"}" class="usercontent">this lovely content.</span></div>          </div>       </div>    </div>    <div class="fbtimelineufi uicommentcontainer">       <form rel="async" class="live_644752595561563_316526391751760 commentable_item hidden_add_comment collapsed_comments" method="post" data-ft="{"tn":"]"}" action="/ajax/ufi/modify.php" data-live="{"seq":0}" id="u_jsonp_2_l" onsubmit="return window.event &amp;&amp; event.__inlinesubmit &amp;&amp; event.__inlinesubmit(this,event)"><input type="hidden" name="charset_test" value="€,´,€,´,水,Д,Є"><input type="hidden" name="fb_dtsg" value="aqenpachtshg" autocomplete="off"><input type="hidden" autocomplete="off" name="feedback_params" value="{"actor":"100000804868370","target_fbid":"644752595561563","target_profile_id":"100000804868370","type_id":"22","assoc_obj_id":"","source_app_id":"0","extra_story_params":[],"content_timestamp":"1396685690","check_hash":"aqcgtxzwjmvep6rw","source":"13"}"><input type="hidden" autocomplete="off" name="data_only_response" value="1"><input type="hidden" autocomplete="off" name="timeline_ufi" value="1"><input type="hidden" name="timeline_log_data" value="aqcj-vvlcudba-dhyf87robxsove5vhgs-ph8fa7zccxtq7gvnzgsjobxbakcwqlc9wfu-ssdvesf2bqdiqr3jlj06ny4px5aelfdrtctjlnvtr-goizu28gkgnoxjo1rjajxfhmze2sqliy1usuumqjqbxd4xwyy44ikaqy36e4d-olzc33tzswlgiak2l2xwyr8wyyvrkn2tgjpc8esb-yk87ysvwtcrnacwg7zk3yuq7tar8f3ifdc9vda0rap-1v_exr_unjdixifu3slasmoexuthv2zalmucqpukz3cudowzxgzhyohw3tuty8t1lx8quz_mz_ut5pf9kjr2w7e7pzxvl19uvpj7nqhm0hynxorpj0dsashbcbu4ijt71tsyzszhrmapcjpi1zdhuarornwoxar-_ici9dzsbrxq">       <div class="fbtimelinefeedbackheader">          <div class="fbtimelinefeedbackactions clearfix"><span class="ufiblingboxtimeline"><span data-reactid=".j"></span></span><span class="uiactionlinks uiactionlinks_bottom" data-ft="{"tn":"=","type":20}"><span><a class="ufilikelink" href="#" role="button" aria-live="polite" title="like this" data-ft="{"tn":"&gt;"}" data-reactid=".k">like</a></span> · <label class="uilinkbutton comment_link" title="leave comment"><input class="uilinkbuttoninput" data-ft="{"type":24,"tn":"s"}" type="button" value="comment" onclick="return fc_click(this);"></label> · <a class="share_action_link" href="/ajax/sharer/?s=22&amp;appid=25554907596&amp;p%5b0%5d=100000804868370&amp;p%5b1%5d=644752595561563&amp;profile_id=100000804868370&amp;share_source_type=unknown" rel="dialog" data-ft="{"tn":"j","type":25}" title="send friends or post on timeline." role="button">share</a></span></div>       </div>       <div>          <div class="uiufi uficontainer" id="u_jsonp_2_t">             <ul class="ufilist" data-reactid=".l">                <li class="ufirow  uficomponent ufiaddcomment ufiaddcommentwithphotoattacher ufifirstcomponent ufilastcomponent" data-ft="{"tn":"["}" data-reactid=".l.1:4">                <div class="clearfix ufimentionsinputwrap" data-reactid=".l.1:4.0">                   <div class="_ohe lfloat" data-reactid=".l.1:4.0.$left">                      <div class="img _8o _8r ufiimageblockimage ufireplyactorphotowrapper" data-reactid=".l.1:4.0.$left.0"><img class="img ufiactorimage _54ru" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t1.0-1/c5.5.64.64/s32x32/1010859_539620286074795_1558724572_t.jpg" alt="adnan ahmad siddqi" data-reactid=".l.1:4.0.$left.0.0"></div>                   </div>                   <div class="" data-reactid=".l.1:4.0.$right">                      <div class="ufiimageblockcontent _42ef _8u" data-reactid=".l.1:4.0.$right.0">                         <div class="uficommentcontainer" data-reactid=".l.1:4.0.$right.0.0">                            <div class="ufiinputcontainer" data-reactid=".l.1:4.0.$right.0.0.0">                               <div class="uimentionsinput textboxcontainer reactlegacymentionsinput" data-reactid=".l.1:4.0.$right.0.0.0.0">                                  <div class="highlighter" data-reactid=".l.1:4.0.$right.0.0.0.0.0">                                     <div data-reactid=".l.1:4.0.$right.0.0.0.0.0.0"><span class="highlightercontent hidden_elem" data-reactid=".l.1:4.0.$right.0.0.0.0.0.0.0"></span></div>                                  </div>                                  <div class="uitypeahead mentionstypeahead" data-reactid=".l.1:4.0.$right.0.0.0.0.1">                                     <div class="wrap" data-reactid=".l.1:4.0.$right.0.0.0.0.1.0">                                        <input type="hidden" autocomplete="off" class="hiddeninput" data-reactid=".l.1:4.0.$right.0.0.0.0.1.0.0">                                        <div class="innerwrap" data-reactid=".l.1:4.0.$right.0.0.0.0.1.0.1"><textarea name="add_comment_text" class="textinput mentionstextarea uitextareaautogrow uitextareanoresize ufiaddcommentinput domcontrol_placeholder" title="write comment..." placeholder="write comment..." value="write comment..." data-reactid=".l.1:4.0.$right.0.0.0.0.1.0.1.0">write comment...</textarea></div>                                     </div>                                  </div>                                  <input type="hidden" autocomplete="off" class="mentionshidden" value="" data-reactid=".l.1:4.0.$right.0.0.0.0.2">                               </div>                               <div class="uficommentattachmentbuttons clearfix" data-reactid=".l.1:4.0.$right.0.0.0.1">                                  <div class="ufiphotoattachlinkwrapper _m" data-hover="tooltip" data-tooltip-alignh="center" aria-label="attach photo" data-reactid=".l.1:4.0.$right.0.0.0.1.0"><i class="uficommentphotoicon" data-reactid=".l.1:4.0.$right.0.0.0.1.0.0"><input type="file" accept="image/*" class="_n" name="file" title="choose file upload" aria-label="choose file upload"></i></div>                               </div>                            </div>                         </div>                      </div>                   </div>                </div>                </li>             </ul>          </div>       </div>       </form>    </div>    <div class="_5ce">       <div class="_5m- lfloat"><i class="_5n0"></i></div>       <div class="_6a uipopover _5d68" id="u_jsonp_2_4"><a class="_dxs _p" aria-label="options story" href="#" aria-haspopup="true" aria-expanded="false" rel="toggle" role="button" id="u_jsonp_2_5"></a></div>    </div> </div> </div> 

my question is, using jquery, can access following html directly referring class timelineunitcontainer?

<div class="usercontentwrapper">                 <div class="_wk"><span data-ft="{"tn":"k"}" class="usercontent">this lovely content.</span></div>              </div> 

it's not quite clear you're asking, if goal access divs usercontentwrapper, don't need timelineunitcontainer anything:

var divs = $("div.usercontentwrapper"); // or ".usercontentwrapper" 

that looks div elements class. (or if leave off div part, elements of type class.)

if it's important @ ones in timelineunitcontainer, then:

var divs = $(".timelineunitcontainer div.usercontentwrapper"); 

(or, again, can leave off div if it's not important.) looks ones inside ("descendants of") elements class timelineunitcontainer.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -