var fare_cal_route = ''; var hour = ''; $(document).ready(function() { if (document.getElementById("fare_select_route_div")){ document.getElementById("fare_select_route_div").innerHTML=fare_cal_route; } if (document.getElementById("hour_div")){ document.getElementById("hour_div").innerHTML=hour; } })