jQuery: Small utility to set CSS display type
Showing elements with jQuery's native .show() sets display as 'inline', but sometimes we need to set 'flex' or 'inline-block'.
This commit is contained in:
parent
ac3a599bb6
commit
2332bc0960
@ -64,4 +64,13 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
// jQuery's show() sets display as 'inline', this utility sets it to whatever we want.
|
||||
// Useful for buttons or links that need 'inline-block' or flex for correct padding and alignment.
|
||||
$.fn.displayAs = function(display_type) {
|
||||
if (typeof(display_type) === 'undefined') {
|
||||
display_type = 'block';
|
||||
}
|
||||
|
||||
this.css('display', display_type);
|
||||
}
|
||||
}(jQuery));
|
||||
|
Loading…
x
Reference in New Issue
Block a user