jQuery dynamically change onclick location.href

specked picture specked · Oct 6, 2010 · Viewed 10k times · Source

This works in firefox but doesn't do anything in 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 + "\'\;");
    }

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

Is there another way to do this?

Answer

Chinmayee G picture Chinmayee G · Oct 6, 2010

try this

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