I'm having trouble concatenating a String with " and '.
I want to send a command to Jquery click on a div that has a title that I pass as a parameter.
Need to obtain this to execute in a jquery function:
jQuery('div[title=\"titletoclick\"]').trigger( 'click' );
I have this function:
function clickOnMarker() {
let queryString = window.location.search;
let urlParams = new URLSearchParams(queryString);
let spotNameOriginal = urlParams.get('markerName');
let spotName = spotNameOriginal.slice(1,-1);
let elementToClick = "'div[title=\'" + spotName + "'\]'"
jQuery(elementToClick).trigger( 'click' );
}
When executing the function I have an error because the value of the variable is
'div [title =' Sintra Spot ']'
I need to put the " " in the title and not the ' ' and remove spaces TRIM().
Best regards and thanks