如何在HTML中创建自定义标签? [英] How to create custom tags in HTML ?

查看:126
本文介绍了如何在HTML中创建自定义标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



首先,我想用HTML创建自定义标签

< language>



当我运行HTML页面时,我希望这个标签会自动调用JavaScript函数。





谢谢你提前



Abhinandan

Hi

First I want to create custom tags in HTML
<language>

When i run the HTML page then i want this tag will automatically call JavaScript function.


Thanks in advance

Abhinandan

推荐答案





我担心无法在HTML中创建自己的标签。但是,如果要在HTML中调用JavaScript,则应使用 ... 定义脚本,然后将其作为某个事件的处理程序调用。



问候,

Jan Kucera
Hi,

I am afraid it is not possible to create your own tags in HTML. However, if you want to call a JavaScript in HTML, you shall define the script with ... and then call it for example as a handler of some event.

Regards,
Jan Kucera


这是一个用于显示闪烁字符串的示例脚本:





This is a sample script i use to show a blinking string:


<script type="text/javascript">
    function doBlink() {
           var blink = document.all.tags("alarm") // <-- GET THE TAGS

           for (var i = 0; i < blink.length; i++)

               blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""

       }



       function startBlink() {

           if (document.all)

               setInterval("doBlink()", 1000)

       }

         window.onload = startBlink;

   </script>

   ...

   <alarm><asp:Label ID="lblAlert" runat="server" Text="ALARM!"></asp:Label></alarm>


你可以使用onload函数来调用脚本。但是,如果您想使用Jquery或其他一些

,那么您将获得更高效的处理它的其他功能。



这是其中一个

http://api.jquery.com/ready/ [ ^ ]
You can use onload function lo call the script. However if you like to use Jquery or some other
then you will get other features which will handle it with more efficient.

Here is one of them
http://api.jquery.com/ready/[^]


这篇关于如何在HTML中创建自定义标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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