In case of any contest under section 23-24 of this Act, the court shall allow any one or more electors of the State or political subdivision to appear and intervene in such proceedings for the purpose of participating in the prosecution or defense of the same. In case the judgment of the court shall be contrary to the contentions advanced by such interveners, the court may in its discretion tax against such interveners the cost of such proceedings or such portion thereof as to the court shall seem proper.
10 ILCS 5/23-25