简体   繁体   中英

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

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

 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();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM