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')


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -