Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7090853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:06:28+00:00 2026-05-28T08:06:28+00:00

I have an input that contains a text. When I click into this input,

  • 0

I have an input that contains a text. When I click into this input, so the color of the text will change. In the input is eg. the text ‘Hello buddy’ – and when I click into the input in the end of the word Hello, so exist any easy way to set the cursor on the start (before the word Hello)?

$('#your_name').focus(function(){
    if($(this).val() == $(this).attr('title')){
        $(this).css('color', 'red');
    }

    $(this).keyup(function() {
      $(this).val('');
    });
});

And when I start to type a text into the, how can I remove the current text Hello buddy and have in the input only the “new” text? I am trying to do with keyup method, but everything what I type is deleted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:06:29+00:00Added an answer on May 28, 2026 at 8:06 am

    See my DEMO here. Also modified your jsFiddle.. see here

    Edit: You can just use el.setSelectionRange(index, index); to set the caret position.

    And for your second question about removing the whole text when you keyup, You can use .one method which will executed only once.,

    $(this).one('keydown', function() {
          $(this).val('');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DIV that contains many input text. I need a way in
I have an array of input strings that contains either email addresses or account
I have a php file that contains a form (which contains 2 input boxes
In my HTML code, I have a form tag that contains two input boxes,
We have some input data that sometimes appears with &nbsp characters on the end.
I have an input field that is by default set to type=text so that
So I have a INPUT TEXT that upon keypress=enter prepends an LI to an
I have written a user control that contains a text box and a button.
I have created an Ajax enabled WCF web service that contains this simple method:
i have this form: <form name=myForm action=#> <input type=text name=firstField /> <input type=text name=secondField

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.