Some Jquery tips !


In my project i have a problem in focus . I created text box using for loop . so i have focus problem.

Then I solved that problem . There are many jquery API to help us 🙂

Example :


<script type = "text/javascript">
$(document).ready(function() {
$(".main_text_box").blur(function() {
value_of_text_box = parseInt($(".main_text_box").val());
$(".sub_text_box_div").empty();
for (iter1=0;iter1<value_of_text_box;iter1++) {

$(".sub_text_box_div").append("<div class = 'text_box' ><tr><td>value :</td><td><input type = 'text' class = 'sub_text_box_id' onblur = 'sub_text_box_function(this)'><div class = 'inner_text_box'></div></td></tr></div></br>")
$(".sub_text_box_id:first").focus();
}

});

});

</script>

Some Jquery API which helped me today

1.      $(“.sub_text_box_id:first”).focus();          – this will focus textbox in first classname as  “sub_text_box_id”

2.      $(“.sub_text_box_id:eq(0)”).focus();  0r $(“.sub_text_box_id”).eq(0).focus();      – is same as first one i mentioned .

and we can traverse to any number of class like specifying eq(1) , eq(2)   {third text box with same class name}

3.    $(“.sub_text_box_id:last”).focus();   –   this will focus textbox in last classname as  “sub_text_box_id”

4.    $(“tr:even”).css(‘background-color’,’red’)   – this will change color to even rows of table


Regards

sathia

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in programs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s