jQuery动态更改onclick location.href

时间:2010-10-06 12:34:59

标签: javascript jquery location-href

这适用于Firefox,但在IE中没有做任何事情:

            $("#_results").autocomplete({
                source: data,
                minLength: 0,
                select: function(event, ui) {
                    $("#log").empty();
                    log(ui.item.lname + ", " + ui.item.fname + " " + ui.item.sso);
                    log("Currently in " + ui.item.currentRotation + " rotation");
                    log("Graduated from: " + ui.item.college);
                    log("More details can be viewed by clicking here");
                    $("#log").attr("onclick", "location.href=\'" + ui.item.dataformEntry + "\'\;");
                }

具体为$("#log").attr("onclick", "location.href=\'" + ui.item.dataformEntry + "\'\;");

还有其他办法吗?

由于

2 个答案:

答案 0 :(得分:3)

试试这个

$("#log").click(function(){
     location.href= ui.item.dataformEntry;
});

答案 1 :(得分:1)

你已经尝试了

$("#log").bind("click", function() { 
    location.href = ui.item.dataformEntry 
});