可以使用jQuery将嵌套元素的文本存储在变量中吗?就我而言,内容是'SEO SEM'。
我唯一的参考是名为event_490
的第一个类,我希望得到类evcal_event_title
的子元素的内容等于'Seo SEM'。
<div class="evo_lightbox_body eventon_list_event evo_pop_body evcal_eventcard event_489">
<div class="evopop_top" style="border-left-width: 3px; border-left-style: solid; border-left-color: rgb(33, 119, 189);">
<span class="ev_ftImg" data-img="http://localhost/academia/wp-content/uploads/2016/05/JBW2PXDOL6.jpg" data-thumb="http://localhost/academia/wp-content/uploads/2016/05/JBW2PXDOL6.jpg" style="background-image:url(http://localhost/academia/wp-content/uploads/2016/05/JBW2PXDOL6.jpg)"></span>
<span class="evcal_cblock " data-bgcolor="#2177bd" data-smon="junho" data-syr="2016">
<em class="evo_date">
<span class="start">11<em>jun</em>
</span>
<span class="end"> - 12</span>
</em>
<em class="evo_time">
<em class="evo_day">jun 11</em>
<span class="start">9:00</span>
<em class="evo_day end">jun 12</em></em>
<em class="clear"></em>
</span>
<span class="evcal_desc evo_info hide_eventtopdata " data-location_status="false">
<span class="evo_above_title"></span>
<span class="evcal_desc2 evcal_event_title" itemprop="name">Digital Stratety</span>
<span class="evo_below_title">
<span class="evcal_event_subtitle">09:00 - 18:00 | 16h | 155€</span>
</span>
<span class="evcal_desc_info"></span>
<span class="evcal_desc3"></span>
</span><em class="clear"></em>
</div>
</div>
答案 0 :(得分:3)
如果页面中的类没有重复,您可以使用类选择器.
和text()
函数:
$('.event_490 .evcal_event_title').text();
希望这有帮助。