[jQuery] access an element with 2 classes

2007-02-26 Thread Timothy Bowler
Hi,

I am creating tooltips for a form. The text that appears in the tooltip will 
have two classes:

span class=info email-infoText./span
span class=info password-infoText./span

First how can I access all the elements that contain 'info' in their class?
Secondly when the user clicks on the input box i need to access the second 
class so i know which one it is, how can I do that?


Thank you in advance

Tim___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] access an element with 2 classes

2007-02-26 Thread Karl Rudd
First bit is easy:

// All spans with class=info
var infoSpans = $('span.info');

Second bit depends on how you have structured your HTML. Assuming the
following HTML:

span class=info email-infoText./span
input class=hasInfo type=text ...

Script (untested):

$(function() {
  $('input.hasInfo').click( function() {
var infoSpan = $(this).prev('span.info');

// do whatever with the span

// show it
infoSpan.show();

// test if it's a particular class
if ( infoSpan.is('.email-info') ) {
  // do something
}
  });
});

Karl Rudd

On 2/27/07, Timothy Bowler [EMAIL PROTECTED] wrote:


 Hi,

 I am creating tooltips for a form. The text that appears in the tooltip will
 have two classes:

 span class=info email-infoText./spanspan class=info
 password-infoText./span

 First how can I access all the elements that contain 'info' in their class?
 Secondly when the user clicks on the input box i need to access the second
 class so i know which one it is, how can I do that?


 Thank you in advance

 Tim
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/