change data-target jquery code example Example: how to add data modal target attribute in jquery $('#testButton').attr('data-target','#testModal2');