I'm not sure how custom attributes work, but I do know that code won't work. You're going to want to do something like this:
function search_by()
{
var search_term = $('.search_for').attr('search_for');
alert(search_term);
}
Pay close attention to the fact that my selector is looking for a class, not an ID (which is denoted with a # symbol).
You could also shorten it to be:
function search_by()
{
alert($('.search_for').attr('search_for'));
}