How to find visible class based on partial id and then return full id in jquery -
how find visible class based on partial id , return full id in jquery, here of code better understanding. <div class="visible" id="fares-and-payments-1-10kms"> </div> <div class="hidden" id="fares-and-payments-11-20kms"> </div> <div class="hidden" id="fares-and-payments-21-30kms"> </div> so if take snippet above want return "fares-and-payments-1-10kms" id div has class visible. the elegant , efficient way awesome. you use attribute starts-with selector, in combination class var elem = $('[id^="fares-and-payments"].visible'); that gets element, if need id, you'd elem.prop('id')