日期:2014-05-16  浏览次数:20400 次

如何才能取到下面这个值
var value1 = $('div.m_con.m_jk div:visible div.m_progress.progress1 .num').text();
为什么这样出来的话会有1001000   2个值 ,如何才能只取到100这个值 ?

<div class="m_con m_jk">
<div id="tab1">
<div class="m_jk_c m_tab_c">
<div style="display: block">
<table>
<tr>
<td class="wd1"><span class="m_ico2_1"></span></td>
<td class="td1"></td>
<td colspan="4">
<div class="m_progress progress1">
<div class="m_progress_start">500</div>
<div class="m_progress_range">
<div class="m_progress_percent_bg">
<div class="m_progress_percent"></div>
</div>
<div class="m_progress_cursor"></div>
<div class="m_progress_cursor_title">
<span class="num">100</span>
<div class="corner"></div>
</div>
</div>
<div class="m_progress_end">3000</div>
</div>
</td>
</tr>


</table>
</div>
<div style="display: none">
<table>
<tr>
<td class="wd1"><span class="m_ico2_1"></span></td>
<td class="td1"></td>
<td colspan="4">
<div class="m_progress progress1">
<div class="m_progress_start">100</div>
<div class="m_progress_range">
<div class="m_progress_percent_bg">
<div class="m_progress_percent"></div>
</div>
<div class="m_progress_cursor"></div>
<div class="m_progress_cursor_title">
<span class="num">1000</span>
<div class="corner"></div>
</div>
</div>
<div class="m_progress_end">3000</div>
</div>
</td>
</tr>


</table>


</div>
</div>
</div>
</div>

------解决方案--------------------


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
$(".m_jk_c table div:visible .m_progress_cursor_title span").each(function(){
alert($(this).text());
})
})
</script>
<div class="m_con m_jk">
 <div id="tab1">
 <div class="m_jk_c m_tab_c">
 <div style="display: block" number="0">
 <table>
 <tr>
 <td&nb