Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery animate Text value

I have html input

<input id="txtSearch" value="Search..." type="text"/>

Is it possible to animate the value of this text input (i.e fadeout, hide, etc..)

    $("#txtSearch").focusin(function () {
        $(this).animate({ opacity: "1", left: "-=100px", width: "+=100px" }, 1000, function () {
            $(this).attr("value", "");
        });
    });

Instead of making $(this).attr("value","") i want to make the vlaue of this text disappear away with an animation like fadeout or hide.

like image 544
Mahmoud Gamal Avatar asked Apr 06 '26 06:04

Mahmoud Gamal


1 Answers

The problem cannot be solved as you described it.

The only solution is to overlay an element (ie: span) over the text field, with exact same size and then put your text into that.

In later step you can make any animation possible to that html element and after effect is completed give the focus back to the text element.

like image 66
KodeFor.Me Avatar answered Apr 08 '26 22:04

KodeFor.Me



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!