Web Analytics Made Easy -
StatCounter detecting class names - CodingForum

Announcement

Collapse
No announcement yet.

detecting class names

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • detecting class names

    mhh...

    I need a script that could do different functions depending on the class name of a element being moused over.

    for example:

    <img src="my moma.jpg" class="FADEIT">

    from this class my code will know to fade it in or out and i can do that just fine by doing something like e.className=="FADEIT"

    however how can i do something like this:

    <img src="my moma.jpg" class="FADEIT+BLINK">

    from this class name my js should know to do something that corrospons to FADEIT and to BLINK but i do NOT want it to check for the className="FADEIT+BLINK" i want it to check weather or not FADEIT is in the class name or not, if it is in then do something.

    so how could i approach this? (Maybe index of?--> I dont know how to use that on className tho, so if you think that is a possibility please explain it to me, thx)

    thanks for any help and please post back to me if you did NOT understand me (happens quit often )

    thanks
    http://www.bluephoenix.uni.cc/

  • #2
    Yea I don't get it...

    So when you say you want class="FADEIT+BLINK", but you don't want to check for it, what do you mean exactly? What do you want to check for? You'd have to check for something...

    Is it possible for class="FADEIT" (ie. FADEIT without BLINK)?
    Or can FADEIT+somethingelse be possible?

    Because if that is a possibility, then you'd have to check further than FADEIT.

    Let us know,
    Sadiq.

    Comment


    • #3
      here is what i mean....

      a img with the class name="FADEIT" would automatically open a function that would for example fade teh image (just by checking if the className is equal to FADEIT)

      a img with the class name="BLINK" would automatically open a function that would for example Blink the image (just by checking if the className is equal to BLINK)

      But now i also want it to fade the image and blink it when FADEIT or BLINK is included in the class name.

      so this should make the image blink:

      <img class="BLINK+something">
      this should make it BLINK and fade
      <img class="BLINK+FADEIT">

      understand it now?

      thanks for your help so far
      http://www.bluephoenix.uni.cc/

      Comment


      • #4
        Use indexOf

        so how could i approach this? (Maybe index of?--> I dont know how to use that on className tho,
        Use indexOf the same way as you use it in ordinary strings.

        if (obj.className.indexOf("FADEIT")!=-1)
        //exists
        else
        //does not exist
        Glenn
        vBulletin Mods That Rock!

        Comment


        • #5
          cool thanks alot
          http://www.bluephoenix.uni.cc/

          Comment

          Working...
          X