如何在数据列表中应用JavaScript [英] how to apply javascript in datalist

查看:78
本文介绍了如何在数据列表中应用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Friends ..

当我将Javascript应用于数据列表的每一行时,它仅应用于数据列表的第一行,而其他行保持静态.

为什么会这样?

我在数据列表的每一行中应用Javascript的任何解决方案?

Hi Friends..

when I apply Javascript in each row of datalist,it apply only on first row of datalist while others rows are remaing static.

why this happen?

Any Solution that i apply Javascript in each row of datalist?

推荐答案

我不知道我是否很好地理解了这个问题,无论如何,我给出了一些可能的提示有用的

您正在使用getElementById吗?

这就是为什么只有一个元素的原因.
我建议您使用jquery来获取需要处理的项目的集合.

在这里 http://jquery.com/ [ ^ ]

例如:
i don''t know if i understood well the problem, anyway i give some hint that could be usefull

you''r using a getElementById ?

that should be why you get only one element.

i suggest you using jquery to get the collection of items that you need to manipulate.

a lot of stuff can be founded here http://jquery.com/[^]

ex :
<a id="test" class="classTest">text</a>



您可以通过



you can get the element by


(''#test'')或每个与
(''#test''), or every element with the same class as


(''.class '')

在第二种情况下,您可以循环foreach元素并执行所需的操作
(''.classTest'')

in the second case then you can loop foreach element and do what you need


这篇关于如何在数据列表中应用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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