jquery clear values of all input fields except one

I am trying to write a script which clears the value of all input fields except for one. This script is still clearing the DESCRIPTION input field.

jQuery('.campaign-column').not('active').each(function(index){
    if(jQuery('.campaign-column input[name!="DESCRIPTION"]')){
        jQuery(this+':input').val('');
        }
    });

Answers


Simplify:

$('.campaign-column:not(.active) input:not([name="DESCRIPTION"])').val('')

I assume you meant .not('.active') and not .not('active'), since there is no <active> element in HTML. Note, the loop (.each()) in your original code is pointless, since every iteration selects, over and over, the same elements.


Need Your Help

Shared or Team owned Dashboards in Offline Mode

dynamics-crm dynamics-crm-2011 outlook-2010

I have a dashboard 'my stuff' and a team called 'the best team'. I only want members of 'the best team' to be able to see the dashboard 'my stuff'.

Header & Footer Logo

html header footer

How to move my footer logo like my header logo?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.