How to programmatically trigger click event in svg rectangle element element? like :$(\"#targetElm\").triger(\"click\");
You can use Highcharts' internal function called firePointEvent
for this:
var chart = Highcharts.chart('container', {
series: [{
type: 'column',
data: [1],
point: {
events: {
click: function() {
console.log('Click event fired');
}
}
}
}]
});
chart.series[0].points[0].firePointEvent('click');
Live demo: http://jsfiddle.net/BlackLabel/xbkwqzc5/
How about this
document.getElementById("targetElm").dispatchEvent(new Event('click'));
Here's a working example...
document.getElementById("targetElm").dispatchEvent(new Event('click'));
<svg version="1.1" class="highcharts-root" style="font-family:MontserratRegular;font-size:12px;" xmlns="http://www.w3.org/2000/svg" width="441" height="319.5" viewBox="0 0 441 319.5">
<rect id="targetElm" onclick="alert('hi')"/>
</svg>
i.e. create a click event and dispatch it to the element. Although you don't seem to have any handler for the click event in your question.