Reputation: 42957
I am absolutly new in JavaScript and I have the following problem.
I have a script that is automatically performed when the user click on a button.
I need that this script do also the following operations:
Select an element into my DOM that have a specific ID
This element have setted an inline CSS: style="display: block;"
, which have to be removed.
How can I do it?
Upvotes: 1
Views: 130
Reputation: 1167
If you're using vanilla javascript (that is without any library), do the following:
var element = document.getElementById( YOUR_ELEMENT_ID )
element.style.display = ''
You effectively just enter the attribute you want and set it to an empty string.
Upvotes: 1
Reputation: 352
With JQuery you can use $("#ElementID").css("display", "");
to clear the display
attribute.
If it needs to be something else, just change the second parameter in the css()
function.
More info here: http://api.jquery.com/css/
Upvotes: 0
Reputation: 9561
With just JavaScript
<script>
var elem = document.getElementById("your_elem_id");
elem.style.display = '';
</script>
Upvotes: 0
Reputation: 517
$("#id_of_the_element").hide();
or
$('#id_of_the_element').css('display', '');
Upvotes: 3