单击行数据打开div [英] Open a div on clicking the row data

查看:89
本文介绍了单击行数据打开div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,我正试图在点击表格中的数据时打开一个div。

请帮我解决这个问题。

解决方案

withdiv我假设你的意思是html中的div标签。

您的网格,我假设生成后面的代码?



你需要客户端脚本才能做到这一点。使用例如处理打开和关闭div标签的javascript创建一个函数。 (用一个简单的html按钮进行测试,例如)



困难的部分是在行选择上触发onclick事件。 td标签可能支持onclicks,但我不确定tr标签是否可以。 (如果服务器端生成的表首先使用table / tr / td标签)我再次测试这个纯HTML并从那里开始工作。



所以这就是你需要做的事情:

1.创建javascript函数来打开/关闭div标签并测试纯HTML

2.找出什么服务器端生成的表使用html标签。

3.检查以何种方式操作这些标签(例如添加样式,onclick事件,cellpadding,value等属性...如果你找不到它,快速而肮脏的方法是将单元格的内容包装在div标签中并在那里添加onclick。

4.添加onclick事件调用步骤1中生成的函数。



这是一个非常好的起点: javascript参考和教程 [ ^ ]



希望这会有所帮助。

Dear, I am trying to open a div on clicking the data in a row of a table.
Please help me out with this.

解决方案

with "div" I assume you mean a div tag in html.
Your grid, I assume is generated with the code behind?

You''ll need client-side scripting to do that. Create a function with eg javascript that handles opening and closing the div tag. (test with a simple html button eg)

The difficult part will be to fire an onclick event on the row selection. td tags might support onclicks, but I''m not sure if tr tags do. (if the server-side generated table is using table/tr/td tags in the first place) Again I would test this pure HTML first and work up from there.

So here''s what you need to do:
1. create the javascript function to open/close the div tag and test pure HTML
2. Find out what html tags are used by the server-side generated table.
3. Check out in what way you can manipulate those tags (eg. adding properties like style, onclick events, cellpadding, value, ...) If you can''t find it, the quick and dirty way would be to wrap the cell''s content in div tags and add the onclick in there.
4. Add the onclick event that calls the function generated in step 1.

Here''s a very good starting point: javascript reference and tutorial[^]

hope this helps.


这篇关于单击行数据打开div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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