How to apply a CSS class on hover to dynamically generated submit buttons?

Tiny picture Tiny · Mar 6, 2013 · Viewed 130.5k times · Source

I have the following piece of HTML/CSS code which is used to display pages based on the number of rows retrieved from a database.

Upto this there is no question. I want to apply the CSS class something like the following to all of those buttons on mouse hover.

.button:hover {
    border:1px solid #999;
    color:#000;
}

Those buttons with the name attribute btnPage are generated dynamically in a loop. Therefore, I think it is inconvenient to apply the preceding CSS class based on the id attribute.

So, how can this class be applied to those buttons on hover?

Answer

Sowmya picture Sowmya · Mar 6, 2013

Add the below code

input[type="submit"]:hover {
    border: 1px solid #999;
    color: #000;
}

If you need only for these button then you can add id name

#paginate input[type="submit"]:hover {
    border: 1px solid #999;
    color: #000;
}

DEMO