get the_title_attribute by id

hey just look in code and it also support fourth parameter post

global $post;    
the_title_attribute(array('post'=>$post));//post object

or

global $post;
the_title_attribute(array('post'=>$post->ID));//post id

so you can use it like

<a href="https://wordpress.stackexchange.com/questions/111931/<?php echo get_permalink($id); ?>" title="<?php the_title_attribute(array('post'=>$id)); ?>"> //where $id is post id

Important Link

the_title_attribute