How to use jquery to find the element with display=none and return the elements id to a variable?
I don't think that you need to add :hidden
psuedo selector. The following will give you the id of selector irrespective of whether it is hidden or not.
var elementId = $(".galleryitem").attr("id");
but if you add it will be bit faster-
var elementId = $(".galleryitem:hidden").attr("id");