I'm trying to append the following javascript to a div that will appear when the user presses the ESC key. I can't seem to get the JavaScript to display the value of the javascript being used:
$("#json").hide();
$(document).keydown(function (e) {
if (e.keyCode == 27) {
$("#json").append("<script type="text/javascript"> + "window.location.href = '/editorialPortal' + '?' + this.id + '=' + this.options[this.selectedIndex].value;" + "</" + script>").toggle();
}
});
I'm not sure where I'm missing string escaping or a quotation mark.
thisdoesn't refer to a dropdown, it refers to thedocument- andwindow.location.hrefis used to change the page location, andtoggleis used to hide and show an element... there's a lot wrong. What is your end goal?