令牌非法; PHP里面的JavaScript代码[重复]

This question already has an answer here:

I use php in my JavaScript code to print a JavaScript line but I have an error. what am I doing wrong?

<?php  
    if (isset($_GET['dateSelected'])) {
        echo '$("#eliminarCitaBtn").attr("href", "index.php/agenda/eliminarCita/"+event.cita_id+"/?agendaId='.$_GET["agendaId"].'&dateSelected='.$_GET["dateSelected"].');';
    } else {
        echo "$('#eliminarCitaBtn').attr('href', 'index.php/agenda/eliminarCita/'+event.cita_id+'/?agendaId=".$_GET['agendaId'].");";
    }
?>
</div>

You are't closing the quotes at the end of either attr().

There '");'; and there "');";