ARTLoe ARTLoe - 2 months ago 4x
jQuery Question

converting from Javascript to JQuery - Rails 4

Could one kindly advise me how i would write the below javascript in jQuery? i am unsure as my converted code is not working


document.getElementById("userj_cvattachment").onchange = function () {
document.getElementById("uploadFile").value = this.value;


Lets break it down.

  1. You select an element by: document.getElementById("userj_cvattachment")

  2. You attach a handler to its change event: .onchange = function (){ }

    $("#userj_cvattachment").on("change", function(){ });
  3. You select another element by id

  4. You change its value: .value = this.value;

    $("#userj_cvattachment").on("change", function(){