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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:49:25+00:00 2026-06-05T07:49:25+00:00

I have two inputs. I wish them to have gray text when they contain

  • 0

I have two inputs. I wish them to have gray text when they contain the default value. The first input works, however, when the input is in a dialog, the CSS isn’t initially applied. I suppose I can apply the CSS via jQuery when the dialog is opened, however, seems like I shouldn’t need to do this. Any suggestions?

http://jsfiddle.net/pwdB5/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 
<title>Testing</title>  
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery-ui.js"></script> 
<style type="text/css">
input.filter {
    color: #929292;
    font-size: 0.7em;
    width: 120px;
}
</style> 
<script> 
$(function(){

    $('.default-value').each(function() {
        var $t=$(this), default_value = $t.value;
        $t.focus(function() {
            $t.css('color','black');
            if(this.value == default_value) {
                $t.val('');
            }
        });
        $t.blur(function() {
            $t.css('color','#929292');
            if($.trim(this.value) == '') {
                $t.val(default_value);
            }
        });
    });

    $("#open").click(function() {$("#dialog").dialog("open");});
    $("#dialog").dialog({
        autoOpen    : false,
        modal       : true,
        open : function() {$('#dialog').find('input.filter').val('look up trade');}
    });

});
</script>
</head>

<body>
<button id="open">Click</button>
<input type="text" value="default value2" class="default-value filter" name="value2" />

<div id="dialog" title="dialog">
<input type="text" value="default value1" class="default-value filter" name="value1" />
</div>

</body> 
</html> 
  • 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-06-05T07:49:26+00:00Added an answer on June 5, 2026 at 7:49 am

    Its looks like, the style is not applied – because, the field is getting focused.

    Try this:

    $("#dialog").dialog({
        autoOpen    : false,
        modal       : true,
        open : function() {$('#dialog').find('input.filter').val('look up trade').blur();}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two inputs (text fields) required by JQuery Plug-in : <input type=text name=first_name
Say you have two inputs: <input id=input1 type=text/> and <input id=input2 type=text/> such that
i have two text inputs like the following, i don't want to use <form>
I have two input text boxes which are decimal. The sum of the two
Hello I have two text inputs which get their values from a datepicker. What
I have four input fields in a div. The first two are for first
I have two inputs reading into my command prompt, the first being a series
How can i achieve this using jQuery. I have two text inputs on the
Sorry to ask such a basic question. Say, I have two inputs. The first
I have two inputs min, max In the case where min=32 and max=46 then

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.