Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hey everybody...

i m a beginner to jquery...i m stuck with a small easy function, plz help me out...m trying to apply the hide effect on the text property of text box..here is the script i have written....plz post ur reviews


JavaScript
$(document).ready(function () {
        $('#txttitle').click(function() {
            $('.text').hide();
        });
    });
Posted
Updated 10-Jul-12 8:04am
v3
Comments
[no name] 10-Jul-12 10:30am    
If your question is JQuery then why tag it C#?
Shelby Robertson 10-Jul-12 13:50pm    
Adding the HTML that this code applies to would greatly help
Sergey Alexandrovich Kryukov 10-Jul-12 13:58pm    
First, show the relevant part of HTML. Format both code samples. Second, how are you going to show the text again?
--SA
zeryy 11-Jul-12 8:23am    
i actually want to create a textbox with a message written on it 'click to edit', and i want that msg to disappear when i click it to let me type desired text...
Sibasisjena 13-Jul-12 8:27am    
Actualy we can not hide text.We can do one thing the text which you want to hide.Just hide the container of the text.

Sounds like you are trying to create a watermarked text box. The code below will remove the watermark when focus is in the text box. You can also hook the blur event and put the watermark back if the textbox is still empty. I'll leave that as an exercise.

HTML
<input id="mytextbox" type="text" class="mytextbox" value="click to edit" />


JavaScript
$().ready(function(){
   $(".mytextbox").focus(function(){
            $(this).val('');
   });
 });
 
Share this answer
 
Try:
HTML
<input id="btntitle" value="HideTextbox" type="button"/>
<input id="mytextbox" type="text" class="mytextbox"/>

JavaScript
$(document).ready(function () {
    $("input#btntitle").click(function () {
        $("input#mytextbox").hide();
    });
});
 
Share this answer
 
Ok Zery you can do like this
JavaScript
$(document).ready(function () {
        $('#txttitle').click(function() {
            $(this).val("");
        });
    });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900