It was the practice of the Prophet (peace and blessings be upon him):
"When he (peace and blessings be upon him) passed by children, he would greet them with salam."
Hadith Referenceصحیح الجامع الصغیر / حرف الكاف / 5014
Hadith Gradingالألبانی:صحيح
Hadith Takhrij[خ] عن أنس. الصحيحة ١٢٧٨: مختصر مسلم ١٤٣١، الدارمي.