Ester Lin
Ester Lin

Reputation: 617

Javascript style.display taking away <ul> bullets

After a little commenting out I've found that when I run this command in JavaScript the bullets in my unordered list disappear (each "page" is an item in my unordered list.):

pages[i].style.display = "block";

The padding of the ul, however, remains intact. How might I toggle with the style.display of a list item without removing the bullet?

Upvotes: 2

Views: 272

Answers (2)

Leon Adler
Leon Adler

Reputation: 3341

You can use display: list-item or element.style.display = "list-item" if you want to restore it to its previous look.


If you have only set the style in JavaScript like this:

element.style.display = 'none';

You can remove the inline style and reset it to its initial state by setting it to an empty string:

element.style.display = '';

This restores display: list-item for <li> elements, display: inline for <span> elements, display: table for <table> elements and so on.

Upvotes: 3

Josh Crozier
Josh Crozier

Reputation: 240928

Set the display to list-item instead, then (which is the default value for li elements).

In your case, it would be:

pages[i].style.display = 'list-item';

Upvotes: 4

Related Questions