Changing tooltip title using jQuery

You can use class selector like this

<input type="text" name="tooltip" class="samplebox" data-toggle="tooltip" title="Ankit" >

    <script>
    $(document).ready(function(){
        $(".samplebox").mouseenter(function(){
            var word = $(this).value();
            $(this).attr('title', word);
        });     
    });
</script>

This will fire the event on all the text boxes you dont need to create any generic function


If there are no style classes, use the attribute-selector. For a tooltip, there's also the attribute value of data-toggle="tooltip":

$(document).ready(function(){
    $("[data-toggle=tooltip]").mouseenter(function () {
        var $this = $(this);
        $this.attr('title', $this.val());
    });   
});

Demo

Note: For the use with Bootstrap's tooltip you may have to change the attribute data-original-title instead if title to update the content of your tooltip. Have a look at this question