输入元素是否有onload事件? [英] Is there an onload event for input elements?

查看:147
本文介绍了输入元素是否有onload事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当呈现输入元素或任何其他html元素时,是否可以触发Javascript脚本。这个脚本应该在html标签内触发,这样我们就可以将'this'传递给js函数。

Is it possible to trigger a Javascript script, when an input element or any other html element is rendered. This script should be triggered from within the html tag, so that we should be able to pass 'this' to the js function.

推荐答案

不,没有这样的事件。

然而,一个< script> 标签直接放在HTML元素会产生类似的效果:它将在元素呈现后直接执行:

However, a <script> tag placed directly after the HTML element would have a similar effect: It would be executed directly after the element has been rendered:

<input type="text" id="input123" value="Hello World!">

<script>
alert("Input123 is now ready:"+document.getElementById("input123).value);
</script>

但是,在大多数情况下,最好使用文档范围加载(或 DOMReady 或jQuery的 .ready())来启动任何脚本操作。然后DOM将完全就绪。

In most cases, however, it is best to use the document-wide load (or DOMReady, or jQuery's .ready()) to start any script operations. The DOM will be fully ready then.

这篇关于输入元素是否有onload事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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