我可以(在JavaScript中)写一个事件或函数,自动适用于一种HTML标签? [英] Can i (in javascript) write an event or a function that automatically applies to one kind of html tag?

查看:125
本文介绍了我可以(在JavaScript中)写一个事件或函数,自动适用于一种HTML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将 onclick(); 或函数应用于所有< span>< / span> 标记在我的页面中,即使是稍后创建的标记,就像所有这种类型的html标记的通用顺序一样。

I was looking for a way to apply an onclick(); or a function to all the <span></span> tags in my page, even the ones which are created later, like a universal order for all of this type of html tag.

尽管ID类型或任何其他属性只有标签名称。

despite of ID class type or any other attribute only tag name.

编辑:由@mhodges回答介绍

Answered by @mhodges by introducing this

请注意,您应该使用 toLowerCase() too

note that you should use toLowerCase() too

推荐答案

当您使用 onclick 时,您可以使用 $(。classname)

Put a class in them, and then when you use an onclick, you search them with $(".classname")

这篇关于我可以(在JavaScript中)写一个事件或函数,自动适用于一种HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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