Reputation: 4516
I have this elements:
<div class="ELEMENT_LISTY" style="">
<div class="TITLE" id="174">string</div>
<div class="BUTTONY">
<div class="POGLAD"></div>
<div class="ZMIEN_NAZWE"></div>
<div class="USUN"></div>
</div>
</div>
How to select element with class .ELEMENT_LISTY
only when I have id #174
?
Upvotes: 1
Views: 83
Reputation: 50643
You can do:
if ( $('div#174').length ) { //if element #174 exists
$('div.ELEMENT_LISTY').whatever..
}
Upvotes: 0
Reputation: 3657
$('#174').parent()
would do it.
It should be noted that mumerical IDs can be tricky within browsers..you should consider using IDs that start with a letter.
Upvotes: 6