Does anyone know how to format the li
onclick
function when it is a dynamic variable string? Basically I just need to insert a dynamic link parameter into the onclick
openwindow
function. For some reason I a getting an error in ie8 and an error when clicked in firefox. I know there is a way to format this but haven't run across it yet. Any help would be great. Thanks in advance.
function myFunc(xml){
var myDynamicLink = '';
mylist += '<ul>';
$(xml).find("group").each(function(i){//loop through groups
myDynamicLink = $(this).find('course').text();
mylist += '<li><a onclick="openwindow('+myDynamicLink+',800,600);">Go to Course</a></li>';
}
mylist += '</ul>';
$('#myDiv').html(mylist);//Display to the DOM
}
I figured it out just needed a few backslashes and another set of single quotes.
mylist += '<li><a onclick="openwindow(\''+myDynamicLink+'\',800,600);">Go to Course</a></li>';