jquery function not working

Posted by Ankitsrist under jQuery on 3/29/2013 | Points: 10 | Views : 949 | Status : [Member] | Replies : 2
hello,
i have made one jquery function, in which when we focus on textbox its background color should change, but its not working have a look on my code
<script type="text/javascript" src="jquery/jQueryv1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('TextBox').focus(function(){
$(this).css('background-color', '#cccccc');
});
});
</script>
<asp:TextBox ID="TextBox1" runat="server" CssClass="TextBox" meta:resourcekey="TextBox1Resource1"></asp:TextBox>

help will be highly appreciate




Responses

Posted by: Ankitsrist on: 3/29/2013 [Member] Starter | Points: 25

Up
0
Down
i have done it myself, below is my code....
<script type="text/javascript">

$(document).ready(function(){
$('input').focus(function(){
$(this).css('background-color', '#cccccc');
});
});
$(document).ready(function(){
$('input').focusout(function(){
$(this).css('background-color', '#FFFFFF')
});
});
</script>

and there is also an other way without using jquery, just put this input:focus{background-color:#cccccc;} in css file and link ur page with it.....
thanks to myself :)

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 4/26/2013 [Member] Starter | Points: 25

Up
0
Down
Change this
$('TextBox').focus(function(){ 


to...
$('#TextBox1').focus(function() { 


The "#" identifies a control with its id.

Rimi

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response