0

I'm importing jquery-ui-form.css to a page but I want to disable the width attribute of the input class (so it will revert to individual styles set on items).

I've tried:

$( "input" ).css( "width", "" );

to no avail.

I don't want to set it to 0 - just to get rid of that particular declaration.

4
  • If you have set a CSS style on the element, the width attribute will automatically be overridden. Can you post a fiddle which shows the problem. Commented May 29, 2014 at 13:41
  • @sphanley - I saw that posting. That's where I got the notion to try the .css( "width", "" ). Doesn't seem to work in this instance though. Commented May 29, 2014 at 13:46
  • But that's not what the accepted answer in that question suggests doing -- they suggest setting the attributes in question to their default value of 'auto', which is exactly what the answer you've accepted here does as well. The answers should confirm that this is a duplicate. Commented May 29, 2014 at 14:07
  • FWIW: this really isn't a duplicate. Setting the value to "" didn't work. The marked answer was the solution. Commented Jun 2, 2014 at 11:43

3 Answers 3

1

Try this

$("input").width('auto')

http://api.jquery.com/width/

Sign up to request clarification or add additional context in comments.

Comments

1

If you use width as attribute instead of using in style You need to do this:

$("input").removeAttr("width");

Comments

1

I think input is a class of an element. As you mentioned in question:

I want to disable the width attribute of the input class

IF it's a class then, you should use class selector to selecting the element:

Try this:

$(".input").css("width", "auto");

OR

$(".input").width('auto');

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.