How to pass inputbox's id to button id value

Viewed 44

I want to pass the input box id to buttons form attribute value when the input box is edited. i have some code but in do not worked.

Enter name: <input type="text" value="Mickey" id="T" oninput="myFunction(this.id);">

<button type="submit" id="b" form="bf" >submit</button>

<script>
function myFunction(id) {

  $("#b[form='bf']").val(id);
  
  
}
</script>


1 Answers

Is this what you mean?

function myFunction(id) {
  $("#b").attr('form', id);  
}
Related