I am trying to figure out how to hide a button with JQuery using the .prop(hidden: true) method. For some reason, in Chrome when I set this value and view the html, the button has a hidden element, but the button still shows up as visible on the page.
Any ideas?
What you described is actually correct if you happen to use jquery alongside bootstrap4.
just do the following:
$element.prop('hidden', true);
If no bootstrap 4 available it is still works for modern browser.
A button does'nt have a hidden property ?
or
If you want to use prop, then
I would go w/o jquery. (back to the basic)
prop() is a getter function: http://api.jquery.com/prop/ I suggest using hide: http://api.jquery.com/hide/
Your syntax is incorrect, but there's no "hidden" property anyway. You probably want:
or possibly
if you've got a "hidden" class in your CSS.
The incorrect part of your syntax is that the parameters to your function call are expressed incorrectly. Setting a property should look like:
jQuery.prop is intended for HTML attributes only, things defined on the DOM node. CSS styles aren't applicable things to set with prop, and
hidden
just doesn't exist, whereashref
orclass
is applicable. Instead you must use$(el).css('display', 'none')
or$(el).hide()
.