I have a div with a wildcard id. I would like to change the display on the wildcard not the actual element.
#mywildcard{
display:none;
}
<div id = "mywildcard"></div>
When I click a button or something I would like to change the actual property display not add a style to the element.
I want
#mywildcard{
display:block;
}
What I am getting now is
<div id = "mywildcard" style="display:block"></div>
#mywildcard{
display:block;//Firebug show crossed out.
}
I tried
$('#mywildcard).css('display','block'); and it just added a style to that element
What you want is to either use the jquery function .toggle() or .show(), depending on the type of effect you are trying to achieve.
Calling
.toggle()on the element will detect if it is display none, then it will revert back to its default display. If it is currently showing (display:block) then calling.toggle()again will hide the element.If instead you want to do a one time change from
display:nonetodisplay:block, then you’ll want to use the.show()function.To be more specific, let’s say you are trying to attach to
.show()function to form button with an id ofwildcardShowBtn. To achieve that in jQuery you would do: