Getting linear-gradient to work in jQuery

Solution:

You need to use to top instead of top.

Also, you need to pass the variable with ` and ${}.

Also, $(document).on( "click", '#update .acf-button-group' you should pass a Element $("#update") instead of '#update .acf-button-group'.

After all fix, it should work.

 

jQuery(document).ready(function ($) {
  $(document).on("click", $("#update"), function () {
    var color1 = $("#color1 input").val();
    var color2 = $("#color2 input").val();
    //console.log(`linear-gradient(to top, ${color1} 0%, ${color2} 100%)`);
    $("#output .acf-input").css({
      background: `linear-gradient(to top, ${color1} 0%, ${color2} 100%)`,
    });
  });
});

//
#output .acf-input {height:100px}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="color1">
<input type="hidden" name="acf[field_60d4d8ef09c78]" value="#0779bf">
</div>
<div id="color2">
<input type="hidden" name="acf[field_61f4e8ef1957b]" value="#48a9e4">
</div>
<div id ="output">
  <div class="acf-input">xxxxxx</div>
</div>
<button id="update">Update</button>