how to give a link in JS

BR
BR used Ask the Experts™
on
Dear Experts,
I'd like to give a link to on Google map pop up,
I want to give the link but it shows it as plain text,

the code is below,
what do you suggest I should do to get link working?

            var xml = data.responseXML;
            var markers = xml.documentElement.getElementsByTagName('marker');
            Array.prototype.forEach.call(markers, function(markerElem) {
              var id = markerElem.getAttribute('id');
              var name = markerElem.getAttribute('name');
              var address = markerElem.getAttribute('address');
              var type = markerElem.getAttribute('type');
              var point = new google.maps.LatLng(
                  parseFloat(markerElem.getAttribute('lat')),
                  parseFloat(markerElem.getAttribute('lng')));

              var infowincontent = document.createElement('div');
              var strong = document.createElement('strong');
              strong.textContent = name
              infowincontent.appendChild(strong);
              infowincontent.appendChild(document.createElement('br'));

              var text = document.createElement('text');
             text.textContent = address + ' <a href="https://www.mylink.com">Bayi:</a> ' + type ;
              infowincontent.appendChild(text);
              var icon = customLabel[type] || {};
              var marker = new google.maps.Marker({
                map: map,
                position: point,
                label: icon.label
              });
              marker.addListener('click', function() {
                infoWindow.setContent(infowincontent);
                infoWindow.open(map, marker);
              });
            });
          });
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Zakaria AcharkiAnalyst Developer
Distinguished Expert 2018

Commented:
The textContent property sets the given value as a test if you want to set it as HTML code you need to use innerHTML instead like :

text.innerHTML = address + ' <a href="https://www.mylink.com">Bayi:</a> ' + type ;

Open in new window

BRDigital Marketing

Author

Commented:
Dear Zakaria Acharki,
this is perfect, thank you so much.

One more thing please

how can I add the paramater here 'type'?

https://www.mylink/mypage.php?id='type'

text.innerHTML = address + ' <a href="https://www.mylink/mypage.php?id= type ">Bayi:</a> ' + type ;

thank you so much.
BRDigital Marketing

Author

Commented:
Dear Zakaria Acharki,
I updated the my comment above, your help is needed. thank you so much
Analyst Developer
Distinguished Expert 2018
Commented:
Hi brother,

You need something like :

text.innerHTML = address + '<a href="https://www.mylink/mypage.php?id=' + type + '">Bayi:</a>';

Open in new window

BRDigital Marketing

Author

Commented:
thank you brother

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial