Web Analytics Made Easy -
StatCounter getElementBy list - CodingForum

Announcement

Collapse
No announcement yet.

getElementBy list

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

  • getElementBy list

    Would anyone know a link to a site that has a list of all getElementBy selectors?

    Like getElementById or getElementByClassName...

    i know there are alot more but i dont know them
    http://www.bluephoenix.uni.cc/

  • #2
    Re: getElementBy list

    Originally posted by JAVAEOC
    getElementByClassName
    I don't believe that's a valid JS method -- but I'm not 100% sure.

    Comment


    • #3
      I think getElemenById, getElementsByName, & getElementsByTagName are the only ones; others might just be custom methods...
      hmm... ?

      Comment


      • #4
        Well if the objects have all the same tag name, say div, there is a solution to get the objects with a common className (or other Attribute), something like:

        function bla(){
        d = document.getElementsByTagName('div');
        j=0;
        var cl = new Array()
        for(i=0;i<d.length;i++){
        if(d[i].className == 'myclass'){
        cl[j] = d[i];
        j++
        }
        }
        }

        Now you have an array of objects, var cl, with the same className arranged in an incremental order, from top to bottom
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          I think getElemenById, getElementsByName, & getElementsByTagName are the only ones; others might just be custom methods...
          but what about, getElementBySelector and getElementsByAttribute.

          doese anyone know about them?
          Last edited by JAVAEOC; Feb 29, 2004, 09:18 AM.
          http://www.bluephoenix.uni.cc/

          Comment


          • #6
            Originally posted by JAVAEOC
            but what about, getElementsByTagName, getElementBySelector, getElementByClassName, getElementsByAttribute. doese anyone know about them?
            refer here:
            I think getElemenById, getElementsByName, & getElementsByTagName are the only ones; others might just be custom methods...
            hmm... ?

            Comment


            • #7
              so stuff like getElementBySelector doesnt exist?
              http://www.bluephoenix.uni.cc/

              Comment


              • #8
                I don't think so, but of course such things can be simulated -- and many already have -- so by searching, you might find examples of this...
                hmm... ?

                Comment


                • #9
                  My 1st try at weird stuff like this


                  Code:
                  <head>
                  <script>
                    function getElementByAttribute(aAttribute,aValue,aInElement)
                    {
                  	  var ElementVerifier;
                  		var Elements=new Array();
                  	  function SearchElement(aElement)
                  		{ 
                  		  if(aElement==null||aElement==undefined)return
                  		  if(ElementVerifier(aElement))
                  			{ 
                  			  Elements[Elements.length]=aElement;
                  			}
                  			SearchElement(aElement.firstChild);
                  			SearchElement(aElement.nextSibling);
                  		}
                  		
                  		if(aInElement==undefined)aInElement=document.body;
                  		str="if(Element."+aAttribute+"=='"+aValue+"'){return true;}else{return false}";
                  		ElementVerifier=function(aElement)
                  		{
                  		  Element=aElement;
                  			if(aElement.nodeName=='#text')return false;
                  			var E=new Function(str);
                  			if(E()){return true;}else{return false};
                  		}
                  		SearchElement(aInElement);
                  		return Elements;
                    }
                  
                  	
                  	function test()
                  	{ 
                  	  var foundElements=getElementByAttribute('style.width','100px');
                  		alert(foundElements.length);
                  		foundElements=getElementByAttribute('tagName','DIV');
                  		alert(foundElements.length);
                  		foundElements=getElementByAttribute('className','test-');
                  		alert(foundElements.length);		
                  	}
                  	
                  </script>
                  <style>.test{}</style>
                  </head>
                  <body onload="test();">
                    <div style="width:100px">Test</div>
                  	<div style="width:100px">Test</div>
                  	<div class="test">Test</div>
                  </body>

                  Comment


                  • #10
                    Heh. have a look: <http://codingforum.net/showthread.php?s=&threadid=26744>

                    Also, <http://web-graphics.com/mtarchive/000832.php>
                    liorean <[[email protected]]>
                    Articles: RegEx evolt wsabstract , Named Arguments
                    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
                    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

                    Comment


                    • #11
                      thanks lionar, helps alot
                      http://www.bluephoenix.uni.cc/

                      Comment

                      Working...
                      X