当div显示时,文本框和下拉列表被清除 [英] when div shows, text box and dropdownlist cleared

查看:85
本文介绍了当div显示时,文本框和下拉列表被清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是jQuery的初学者。

我在处理代码,我必须清除所有文本字段和下拉列表的值单击可切换div(例如A)。



因此,当A显示时,应清除所有文本框和下拉列表选定值。



我用Google搜索,但找不到具体的解决方案。

请帮助我。



提前致谢,



Amit Pandey。

Hi,
I am a beginner in jQuery.
I working on code, where I have to clear all the text fields' and dropdownlists' value once an anchor is clicked which toggles a div (say A).

So when A is showing, all the textboxes and dropdownlist selected value should be cleared.

I googled it, but couldn't find a concrete solution.
Kindly help me with it.

Thanks in Advance,

Amit Pandey.

推荐答案

好吧,就这样做。



这是你附加点击处理程序的方法:。点击()| jQuery API文档 [ ^ ]。



以下是清理文本值的方法: .val()| jQuery API文档 [ ^ ]。



为该值指定空字符串,就是这样。如果您理解清除的方式不同,请指定其他内容。 :-)



现在,关于下拉列表,没有清除这样的概念。例如,您可以将选择移动到预定义的值,这些值可能在索引0处,也可能不在索引0处。这样的元素就是元素选择。例如,请参阅如何在jQuery中设置下拉框值 [ ^ ]。



-SA
Well, just do exactly that.

This is how you attach a click handler: .click() | jQuery API Documentation[^].

And this is how you clean up text values: .val() | jQuery API Documentation[^].

Assign empty string to the value, that's it. If you understand "clearing" differently, assign something else. :-)

Now, as to the drop-down lists, there is no such concept as "clearing". You can, for example, move selection to your predefined values, which may or may not be at the index 0. Such element it the element select. See, for example, How to set a dropdown box value in jQuery[^].

—SA


这篇关于当div显示时,文本框和下拉列表被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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