Rise_against
Rise_against

Reputation: 1070

jquery select class

I have this code:

<div id='divid'>
  <img class='showimg' src='..' />
  <img class='hideimg' src='..' style='display:none;' />
</div>

And I want to select the image inside the div with class 'showimg'.

I have tried $(#divid.showimg) but that doesnt seem to work.. How can I do this?

Thank you.

Upvotes: 0

Views: 127

Answers (2)

Sarfraz
Sarfraz

Reputation: 382919

You can do this:

$('#divid .showimg')

Upvotes: 2

BoltClock
BoltClock

Reputation: 724592

You need to add a space between the ID and class, otherwise you are trying to select elements with both the ID and the class:

$('#divid .showimg')

Upvotes: 2

Related Questions