通过突出显示隐藏字段 [英] Revealing a hidden field by highlighting it

查看:91
本文介绍了通过突出显示隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好CP,



我目前正在开发一个学习到黑客的网站。我有一些隐藏的输入,当文本的某些部分突出显示时应该显示。有没有办法只使用java脚本?还是有更好的方法吗?



等待你的答案:)

Hi CPs,

I am currently developing a learn-to-hack website. I have some hidden inputs that should be revealed when certain part of the text is highlighted. Is there any way to do it with just java script? Or is there a better way?

Awaiting your answers :)

推荐答案

请原谅我的不愉快问题,但你怎么可能写一些内容来帮助人们学习黑客(顺便说一下?为什么?)如果你不知道最简单的基本技术(到目前为止,不是黑客)?



你可以这样做,例如,使用这个CSS:

Please forgive me my unpleasant question, but how could you possibly write some content helping people to learn "hacking" (why, by the way?) if you unaware of the simplest basic techniques (by far, not hacks) yourself?

You can do it, for example, using this CSS:
input.hidden { color: white; background-color: white; }



不要忘记将类隐藏到输入元素中。



您可以随时使用JavaScript更改任何元素使用的类:


Don't forget to give the class "hidden" to your input element.

You can change the class used by any element using JavaScript at any time:

myElement.className = "someOther class";





请参阅: https://developer.mozilla .org / zh-CN / docs / Web / API / Element / className [ ^ ]。



同一个元素可以有几个类:https://developer.mozilla.org/en-US/docs/Web/API/Element/classList [ ^ ]。



另外,如果你选择使用jQuery,你会发现一切都已经为你完成了。



-SA


您可以通过chan将隐藏输入更改为文本或数字输入字段ging类型属性。哪个不可更改。您无法更改输入元素的属性 type 。因此,您可能必须更改整个元素(在节点处添加新子节点,或者可能显示另一个元素),以便隐藏输入现在显示在屏幕上。
You can change the hidden input to a text or number input field by changing the type property. Which is not alter-able. You cannot change the property "type" of the input elements. So, you might have to change the entire element (, add a new child at the node, or perhaps show another element) so that the hidden input now gets shown on the screen.


这篇关于通过突出显示隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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