我如何识别标签? [英] How can i identify a label?

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

问题描述

如何在javascript上识别标签?


我动态创建标签,并为所有人添加onclick事件。

但我需要识别哪个标签已被点击。


我试图这样做:


labelName.onclick = function(){functionName(nameOfLabel) ;}


但是他没有为每个标签添加参数..函数总是得到最后一个参数。


对不起糟糕的英语,


谢谢

How can i identify a label on javascript?

I create labels dynamically and i add a onclick event for all of them.
But i need to identify which label has been clicked.

I tried to do this:

labelName.onclick = function(){functionName(nameOfLabel);}

but he don′t add the parameter for each label..the function always get the last parameter add.

sorry for the bad english,

thanks

推荐答案

我认为我需要的是将动态参数传递给javascript上的标签事件
what a i think i need is to pass dynamic parameters to a label event on javascript


显示其余代码。


//我根据对XML文件的搜索创建可变数量的标签

//每个标签都会收到ID LabelTest1,LabelTest2,LabelTest3 ......

//以下代码是我试图为标签定义函数的地方...参数
// I create a variable number of labels based on a search on a XML file
// Each label receive the The ID LabelTest1, LabelTest2, LabelTest3 ...
// and the follow code is where i tried to define a function for the labels...changing just the parameter

展开 | 选择 | Wrap | 行号


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

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