Paul Dessert
Paul Dessert

Reputation: 6389

Using CSS on elements created by jQuery

I have a select list that is created on a .click event. It looks like this:

$('<select class="selectStatus" onChange="statusSubmit()"/>')
    .attr('name', 'status')
    .append('<option>Pick one</option>', '<option>Open</option>', '<option>Full</option>', '<option>Canceled</option>')
    .appendTo(this);

In my main styles.css file I added this:

select .selectStatus {
    width:700px;
    padding:0px;
    background-color: green;
}

Shouldn't the css be applied to this select list once it's created?

Upvotes: 1

Views: 56

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324640

You are applying those styles to children of selects with class="selectStatus".

Remove the space: select.selectStatus.

Upvotes: 8

Related Questions