I want to detect and prepare a list of unique class names that are being used inside a given view. Is there a way to do it, apart from manual Ctrl+F search i开发者_开发百科n Aptana/Rubymine?
If you are using jQuery, you can
$.unique($('*').map(function(i, e){return $(e).attr('id')}))
and for classes
$.unique($('*').map(function(i, e){return $(e).attr('class').split(' ')}))
Note that the jQuery documentation at http://api.jquery.com/jQuery.unique/ says that "unique()" does only work on jQuery objects but we are using it here with strings. I just tried it on the stackoverflow site though and it seems to work.
精彩评论