I am sure this is simple, I just dont seem to be able to get my head around it. I am trying to add a value of an attribute on click.
So there is this button
<input domain_id="9" class="home_send_but" value="send" type="button">
And when clicked
$('.home_send_but').click(function(){
domain_id = $(this).attr('domain_id');
$('#send_but').attr('domain_id').val(domain_id);
});
It should add the domain_id of 9 to:
<input domain_id="" id="send_but" type="button" value="Send Now">
However, the domain_id attribute for send_but remains as null.
So how do I add a value to an attribute?
And yes, I know I should be using data attributes.
domain_idglobal because you didn't declare as a variable:var domain_id = $(this).attr('domain_id');