How to select the class or the id of the text box in jquery?

advertisements

Hi all i am working on jquery i have a text area i need to select class for hide functions in jquery once it load it will be displayed when i eneter and when i leave it should hide

here my code follows:

   <script type="text/javascript">
     $(document).ready(function () {
      $('.select').mouseleave(function () {
        $('.select').hide();
      });
    });
   </script>

here my html:

     <textarea  rows="10"  class="select"  id="editor1"> </textarea>

here i have my textarea right i need when entered no function will be fired when i leave the textarea it shouls hide for that i need to call text area with class so i need to how to fine a textarea class any help wil be appreaiated thanks


 $('.select').mouseleave(function () {
    $(this).hide();
 });

Altho you might wanna try:

 $('.select').blur(function () {
    $(this).hide();
 });

And as per your question in title

$('.select') /* This will select every single element
    that has the class "select" */

Whereas

$('#editor1') /* This will select ONLY the first
    element that has the id "editor1" */

And inside any event or func call on an element, $(this) represents the element called:

$(".select").blur(function(e) {
    $(this) // represents the current element losing focus
});