[thelist] Javascript Class Selector

Bob Blackman bob at kaboomconsulting.com
Sun Jan 14 10:49:11 CST 2007


Thanks Volkan,

I appreciate the response.  I'll give it a try and also check out your
references.  I'm a relative newbie in javascript and always open to
learn from others so that someday (soon I hope) I can contribute back to
the community.

Best Wishes,
Bob

Jacksonville, Florida

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of VOLKAN ÖZÇELÝK
Sent: Sunday, January 14, 2007 11:35 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] Javascript Class Selector


Hi Bob,

It's a common need among DOM developers.

s at rdalya [1] has DOMManager.getElementsByClassName [2] specially crafted
for
that:

_this.getElementsByClassName=function(strClassName,elmParentNode)
{
    var children=null,
        i=0;
        result=[];

    elmParentNode=(elmParentNode)?_.o(elmParentNode):document.body;

    children=elmParentNode.getElementsByTagName("*");

    for(i=0;i<children.length;i++)
    {
        if(children[i].className.match(new RegExp("(^|\\s)"+
            strClassName+"(\\s|$)")))
        {
            result.push(children[i]);
        }
    }

    return result;
};

it's not rocket science and most of the libraries out there (prototype,
dojo
etc) has the same functionality built in.

But what you need is simply get an element by class name the function
above will be okay. No need to use a rocket launcher to kill a fly on
the wall ;)

By the way I've removed commercial pricing limitations from s at rdalya.
[3] (many thanks to those who have purchased it a priori. And many
thanks to google ads :) )

For those who are interested I'll replace the current license with a
fairly generous LGPL and continue my development of the API at
sourceforge.net(should they accept my registratin)

I think you understand that it's a hard decision / transition period for
me, because there are users of s at rdalya who have purchase a commercial
license and been using the framework actively on their applications. I
have nothing but a big thank you to offer to them (and I believe most of
them will want a refund rather than a full-hearted "thank you" message).

Anyway, I've made up my decision and will move along my way no matter
what.

[1] http://www.sarmal.com/sardalya
[2] http://sardalya.pbwiki.com/DOMManager
[3] http://www.sarmal.com/sardalya/Commercial.aspx

HTH,
-- 
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/cre8/blog/
+> Going solo in Turkish: http://www.volkanozcelik.com/donkisot/
+> My projects/studies/trials/errors : http://www.sarmal.com/  Sardalya 
+>JavaScript Library: http://www.sarmal.com/sardalya/
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 





More information about the thelist mailing list