如何清除使用jQuery一个DIV所有textboxs? [英] How to clear all textboxs in a DIV using jQuery?

查看:224
本文介绍了如何清除使用jQuery一个DIV所有textboxs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div容器一些ASP textboxs。我只是想清除这些当我点击CLEAR键。

我说的所有文本框通用类文本
然后写这个jQuery

  $(文字)文本();

它不工作。

如何做到这一点?
我需要最有效的code。


解决方案

  $('a.clearButton')。绑定(点击,函数(){
    $('#DIVID输入')VAL('')。
});

注:


  1. 您应该使用 VAL ()而不是文本()。


  2. 您所要求的高效率code - 使用类选择是没有效率的

    无论是使用的ID,或添加标记名称。


I have some asp textboxs in a div container. I just want to clear those when i am clicking the CLEAR button.

I say common class 'text' for all textboxes and then wrote this jQuery

$(".text").text(""); 

It's not working ..

How to do this ? I need the most efficient code .

解决方案

$('a.clearButton').bind('click', function() {
    $('#divId input').val('');
});

Notes:

  1. You should use val() instead of text().

  2. You are asking for efficient code - and using class selector is not efficient.

    Either use id, or add tag name.

这篇关于如何清除使用jQuery一个DIV所有textboxs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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