Loading ...
Sorry, an error occurred while loading the content.

function is_in_attribute- I think You'll find this one good its like an optimize

Expand Messages
  • hans
    // Function is_in_attribute(e, att, v) // Returns true if a given attribute has the given value // Arguments: // att = attribute // e = element //
    Message 1 of 1 , May 3, 2006
    • 0 Attachment
      // Function is_in_attribute(e, att, v)
      // Returns true if a given attribute has the given value
      // Arguments:
      // att = attribute
      // e = element
      // v = value <can be string or array of values

      // ex. usage: if (is_in_attribute(e, "background-color", "#ff0000"))
      { //do stuff
      // its basically a more generic getElementsByClassName see below
      // if (is_in_attribute(e, "className", "my_cool_text")) { //do stuff
      // Richard Maloney 2006 coded for engineX
      // adapted from Jonathan Snook, http://www.snook.ca/jonathan
      function is_in_attribute(e, att, v){
      if (! e.getAttribute(att)) { return;}
      var arrOfValues = [];
      if(typeof v == "object"){ var i= v.length;
      while (i--){arrOfValues.push(new RegExp("(^|\\s)" + v[i].replace(/
      \-/g, "\\-") + "(\\s|$)"));}
      i=arrOfValues.length;
      while (i--){if(arrOfValues[i].test(e.getAttribute(att)))
      {{return true;}}
      else {return false;}}}
      else{
      var oRegExp = new RegExp("(^|\\s)" + v.replace(/\-/g, "\\-")
      + "(\\s|$)");
      if (oRegExp.test(e.getAttribute(att))) {return true;}
      else return false;
      }}// End Function
    Your message has been successfully submitted and would be delivered to recipients shortly.