|
Get
Aug 7, 2006 22:46:17 GMT
Post by crazynarutard on Aug 7, 2006 22:46:17 GMT
function get(tag,parent){ if(parent.getElementsByTagName(tag)[0]) return parent.getElementsByTagName(tag); else if(parent.getElementById(tag)) return parent.getElementById(tag); else{ var tarr = [];var ee; for(var x=0;ee=parent.getElementsByTagName('*')[x];x++){ if(ee.className == tag) tarr.push(ee); } return tarr; } }
|
|
|
Get
Aug 8, 2006 2:42:17 GMT
Post by acoolie530 on Aug 8, 2006 2:42:17 GMT
It might help if you provide a little bit of explanation on this code. From what I see, it looks like it will return the elements with the specific tag name, the element with that id, or the elements with that class name? I do not understand why exactly you made this, because a good coder should know how to fetch a specific node and also, there are many coders who have some classnames, id's, and even tagnames that are the same.
|
|
|
Get
Aug 8, 2006 5:36:13 GMT
Post by crazynarutard on Aug 8, 2006 5:36:13 GMT
Well then they would not have to name their classnames/ids the same as tagnames. And I made it so it's easier to grab the tags/ids/classnames.
|
|
|
Get
Aug 8, 2006 15:13:35 GMT
Post by acoolie530 on Aug 8, 2006 15:13:35 GMT
You call it easier, I call it confusing. The only real thing you changed was shortened the name of the function to get the nodes, which can easily be accomplished with: Node.prototype.getTag = function() { return this.getElementsByTagName(arguments[0]); }
|
|
|
Get
Aug 8, 2006 17:10:49 GMT
Post by crazynarutard on Aug 8, 2006 17:10:49 GMT
You call it easier, I call it confusing. The only real thing you changed was shortened the name of the function to get the nodes, which can easily be accomplished with: Node.prototype.getTag = function() { return this.getElementsByTagName(arguments[0]); } You could use this to grab tags/ids and tags with certain classnames. Also you could grab the tags from any parent and it's cross browser.
|
|
|
Get
Aug 8, 2006 21:29:58 GMT
Post by acoolie530 on Aug 8, 2006 21:29:58 GMT
The first thing is obvious. The second is just plain idiotic. You can use getElementsByTagName on any node, not just document and of course getElementsByTagName is cb
|
|
|
Get
Aug 8, 2006 22:09:14 GMT
Post by crazynarutard on Aug 8, 2006 22:09:14 GMT
The first thing is obvious. The second is just plain idiotic. You can use getElementsByTagName on any node, not just document and of course getElementsByTagName is cb Node.prototype doesn't work in internet explorer. If you don't like the code then don't use it, I posted it here for people who would want to use it. And I fucking hate it when people reply to my posts/codes while all they do is critisize. If you keep doing this shit then nobody will want to post codes here anymore because people like you just can't seem to say anything fucking positive about anything at all.
|
|
|
Get
Aug 8, 2006 22:11:58 GMT
Post by virtuoso on Aug 8, 2006 22:11:58 GMT
Pardon the mini-modding, but let's cut the arguing. *wags finger repetitively*
|
|