如何使HTML表中的内容为只读? [英] How to make content in HTML table to read only.?

查看:84
本文介绍了如何使HTML表中的内容为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何将HTML表中的内容设置为只读或禁用,或者如何使用javascript应用样式表来做到这一点?



How to make content in HTML table to read only.or disabled or how to apply stylesheet to do this using javascript?

thanks in advance.

推荐答案

HTML表本身始终是只读的,但是您可以在其中包含输入元素.您可以禁用或启用它们.

操作应该足够复杂,因此使用jQuery会很好.请参阅:
http://en.wikipedia.org/wiki/JQuery [ http://jquery.com/ [ ^ ].

这是启用/禁用的方式:
An HTML table itself is always read-only, but you can have input elements in it. You can disable or enable them.

The manipulations should be complex enough, so it would be good to use jQuery. Please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^].

This is how you enable/disable:
myInput =


(" ); // 使用选择器的示例;在这种情况下,可以通过id ="myInput" 找到元素 myInput.attr(" " 已禁用"); // 禁用 myInput.removeAttr(" ); // 启用
("#myInput"); //example of using selectors; in this case, element is found by id="myInput" myInput.attr("disabled", "disabled"); //disable myInput.removeAttr("disabled"); //enable



要了解此代码示例,您需要了解jQuery选择器和属性:
http://docs.jquery.com/Selectors [ http://docs.jquery.com/Attributes [ http://api.jquery.com/category/traversing/ [ http://api.jquery.com/category/css/ [ http://docs.jquery.com/Tutorials [ http://docs.jquery.com/Tutorials:How_jQuery_Works [



To understand this code sample, you need to understand jQuery selectors and attributes:
http://docs.jquery.com/Selectors[^],
http://docs.jquery.com/Attributes[^].

If you want to enable/disable element of certain type, you can use type selectors, using '':''.

You will also need to be able to navigate in the table and collect several elements (to be enabled/disabled) at once, especially if you don''t want to give them all distinct id. You can use type selectors or traversing:
http://api.jquery.com/category/traversing/[^].

You cannot apply stylesheet, you can apply styles. To do this, you need to use class and .css methods:
http://api.jquery.com/category/css/[^].

To get started, see:
http://docs.jquery.com/Tutorials[^];
start with this one:
http://docs.jquery.com/Tutorials:How_jQuery_Works[^].

Good luck,

—SA


这篇关于如何使HTML表中的内容为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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