javascript - Getting Error Cannot set property 'innerText' of null -
i have scenario of adding text html element using id. getting error. first html gets dynamically loaded adding add variable
html element using id detail
geocoder.geocode({ 'location': temp1 }, function(results, status) { if (status === 'ok') { if (results[1]) { add = results[1].formatted_address; var marker0 = createmarker({ position: temp1, map: map, }, '<h1>details</h1><p id="detail"></p>'); } else { window.alert('no results found'); } } else { window.alert('geocoder failed due to: ' + status); } }); var geocoder = new google.maps.geocoder; var infowindow = new google.maps.infowindow(); var add; /* * marker creater function (acts closure html parameter) */ function createmarker(options, html) { var marker = new google.maps.marker(options); if (html) { google.maps.event.addlistener(marker, "click", function() { infowindow.setcontent(html); console.log(add); document.getelementbyid('detail').innertext = add; infowindow.open(options.map, this); }); } return marker; }
html getting appended document.getelementbyid('detail')
giving null value.
any appreciated.
Comments
Post a Comment