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 939651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:49:27+00:00 2026-05-15T21:49:27+00:00

I have this code: function beforemouseout() { if ($(this).val() == ”) { $(this).val($(this).attr(‘title’)); }

  • 0

I have this code:

function beforemouseout() {
  if ($(this).val() == '') {
    $(this).val($(this).attr('title'));

  } 
  else {

  }
  setTimeout('beforemouseout()',3000); 
}
$(".other").click(function() {
  $(this).val('');  
  $(".other").mouseout(beforemouseout);
});
<input id="hour" type="text" class="other" autocomplete="off" value="hour" title="hour" />
<input id="hour" type="text" class="other" autocomplete="off" value="minutes" title="minutes" />

But Firebug gives me an error: beforemouseout is not defined.
Why?
I tried it on jsfiddle.net and it doesn’t give an error , but the result is not what I expected.I expected when i click on #hour to hide the text and when onmouseout is triggered to wait 5 second and then – to do the checks

  • 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-15T21:49:28+00:00Added an answer on May 15, 2026 at 9:49 pm

    Change your setTimeout like this:

    setTimeout(beforemouseout ,3000); 
    

    Otherwise it’s looking for beforemouseout in a global context, and if your code isn’t in there (it’s inside/scoped to another closure of any kind), it won’t find it. I’m guessing here that it’s in a ready handler because you’re posting HTML right beside it, meaning you’re taking snippets.

    From an overall standpoint, never pass a string to setTimeout() or setInterval() if you can avoid it, it results in many unwanted side-effects…like this one. Instead, pass a direct reference like I have above, to be entirely explicit and well…make it work 🙂


    Edit (for question comments): it seems what you’re actually after it still a bit different than it’s written. From what I gather you want to delay before restoring the default value to the <input>. There are several ways to do this, here’s one:

    function beforemouseout() {
      if ($(this).val() == '') {
        $(this).val($(this).attr('title'));
      }
    }
    $(".other").click(function() {
      $(this).val('').mouseout(function() {
        setTimeout($.proxy(beforemouseout, this), 3000);
      });
    });
    

    You can give it a try here.
    ​

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code: function DisableDropDownsMonth() { $(.filterDropdown).val(0); $(.filterDropdown).attr(disabled, disabled); } to disable a
I have this code: function noti() { document.title = document.title + 1 } setInterval(noti(),
I have this code: function EnableiPad(event) { var id = $(event.currentTarget).attr(data-id); var status =
I have this code: function Imagehover(obj,img){ jQuery(#+obj.id).attr(src,<?php echo $this->baseurl ?>/templates/codecraft.gr/images/+img+.png); } function Imageclick(obj,img){ jQuery(#+obj.id).attr(src,<?php
I have this code: function Keyboard() { this.log = $('#log')[0]; this.pressedKeys = []; this.bindUpKeys
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div
I have this code: _trackit: function(){ for(var key in this.items.sublinks){ switch(key){ case 'shoes': for(var
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have this code snippet: $(function() { $('.toolbar [id^=button]').on('click', function () { $(this) .css('background-color',

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.