I am writing a popup on map pin click, where the user clicks on a link which initiates a function call. Here's the call that creates the pin
new mapboxgl.Marker(el)
            .setLngLat(marker.geometry.coordinates)
            .setPopup(new mapboxgl.Popup({offset: 25}) // add popups
                .setHTML(popup(marker.properties)))
            .addTo(map);
And here's the popup function
function popup(properties) {
    return '<div>' +
        '<h3>' + properties.partnerName + '</h3>' +
        '<a onclick="mapPinSelect()">' + 'Link' + '</a>' +
        '</div>';
}
Everything works fine, but when I convert my popup method to JQuery, my onClick method stops working.
Here's the JQuery version
function popup(properties) {
    return $('<div>')
            .append($('<h3>').append(properties.partnerName))
            .append($('<a>').click(mapPinSelect).append('Link'))
            .html()
}
What am I doing wrong?
 
    