[英]Append url and redirect onclick
I currently have a function used to get a list of 5 website names (title) as well as 5 urls 我目前有一个用于获取5个网站名称(标题)以及5个网址的列表的函数
The code below is pulling the list of 5 titles but how would I go about append the title so that it will redirect to the url on click 下面的代码提取了5个标题的列表,但是我将如何追加标题,以便单击后将其重定向到url
function getFavorites() {
$.getJSON("/Home/UserFavorites", function (result) {
var options = $("#userfavorites");
List = "";
$('#userfavorites >option').remove();
$.each(result, function () {
options.append($("<option />").val(this.url).text(this.title));
List = List + "," + this.title;
});
}).complete(function () {
$.unblockUI();
});
}
$("#userfavorites").change(function(){
window.location.href = $(this).val();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.