如何找到td内部div的innerhtml [英] How to find innerhtml of a div which is inside td

查看:93
本文介绍了如何找到td内部div的innerhtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<td class="fc-day fc-sun fc-widget-content fc-other-month fc-past fc-first" onclick="alert(this.getAttribute('data-date'));" data-date="2016-05-29">
                              <div style="min-height: 88px;">
                                  <div class="fc-day-number">29</div>
                                  <div class="fc-day-content">
                                      <div style="position: relative; height: 0px;">&nbsp;</div>
                                  </div>
                              </div>
                          </td>



如何使用jquery找到29


How to find 29 from it using jquery

推荐答案

试试这个



try this

onclick="alert(this.getElementsByClassName('fc-day-number')[0].innerText)" 





演示: - JSFiddle [ ^ ]


查看查询文档



选择元素jQuery学习中心 [ ^ ]



选择器| jQuery API文档 [ ^ ]



.find()| jQuery API文档 [ ^ ]
Look at the query docs

Selecting Elements | jQuery Learning Center[^]

Selectors | jQuery API Documentation[^]

.find() | jQuery API Documentation[^]


更好的选择是使用JQuery。如果您在每一行中有多个div的表具有相同的类,您可以使用以下行访问所有这些:



A much better option would be to use JQuery. If you have table with multiple "div" in each row with the same class you can access all of them using the following line:

var innerDivs =


这篇关于如何找到td内部div的innerhtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆