javascriptjqueryjquery-selectorsjquery-attributes

Whats a cleaner way to append something to a link URL?


I've got this code so far, which isn't working:

$('.passName').click(function(){
    var schoolName = "18734";
    var link = $(this).attr('href');
    var newLink = link + schoolName;
    $(this).attr('href') = newLink;
});

Solution

  • Do the following:

    $(this).attr('href', newLink);