1

I have an element in my html with this markup:

<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" role="tabpanel" style="width: 98px; display: block;">

I would like to know how to remove the width attribute using jQuery

3
  • what do you mean by remove? Commented Oct 17, 2016 at 9:14
  • you want to change width or remove the attribute width? Commented Oct 17, 2016 at 9:16
  • 3
    .css('width', 'auto') Commented Oct 17, 2016 at 9:16

5 Answers 5

2

You can remove any inline css attribut with this code :

$(selector).css("attribut", "");

So, in your case, use this :

$(".ui-accordion-content").css("width", "");
Sign up to request clarification or add additional context in comments.

4 Comments

You would probably be better off in the long run if you can add the width to a css class instead. $('.ui-accordion-content-active').removeClass('customWidth');
Not sure why people would downvote a corret answer. Additional note: Doing so you can also enter new values for your css attribute.
Why other people all propose to change the value, when bodzilla ask to remove the value ...
@Bazaim Yes I want to remove the attribute completely, therefore this solution works best.
2

This will work for you,

$(".ui-accordion-content").css('width', 'auto;'); 

This will make the div to default width. i.e 100%.

Comments

1

You can set the width to be auto.....

$("selector").css('width','auto');

Comments

0

you could use

.css('width', 'auto')

Comments

0

Use this -

$(".ui-accordion-content").css('width', 'auto');

or assign a ID to div id='myDivId'

$("#myDivId").css('width', 'auto');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.