如何在javascript中获取此元素的innerHTML? [英] How to get innerHTML of this element in javascript?

查看:77
本文介绍了如何在javascript中获取此元素的innerHTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常简单的问题。我有一个元素(标签),它有一个onclick来调用javascript函数。在其他方面,我希望这个函数能够回显调用它的元素的innerHTML。因此,在这种情况下,atag的innerHTML。

Pretty simple question. I have an element (a tag) which has an onclick to call a javascript function. Amoung other things, I want this function to echo the innerHTML of the element that called it. So, in this case, the innerHTML of the atag.

我该怎么做?

推荐答案

<element onClick="alert(this.innerHTML);"> ... </element>

这篇关于如何在javascript中获取此元素的innerHTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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