RobertD RobertD - 4 years ago 219
CSS Question

Hide select option before last CSS

I use this line to hide the last option in a select, I need only CSS:

.form-search > select option:last-child {display:none;}

how I can do to hide the previous option, the option that is before last?

Can be selected by value? for example the last has 55 value and the option before last has 54 value.
Thank you

Answer Source

You use nth-last-child(2).

Like this:

.form-search > select option:nth-last-child(2) { display:none; }

You can read more here:

This is supported in IE 9+, Chrome 4+, FF 3.5+, Safari 3.2+

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download