Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery vs Dojo

 
Jon Fisher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm evaluating Dojo vs Jquery. Here is a practical example where Dojo is losing in terms of simplicity. Can someone tell me if there's a better way to do this with dojo?

** Code cleanliness- how would one go about striping a HTML table

Dojo:
dojo.lang.forEach(document.getElementsByTagName("table"), function(table){
dojo.lang.forEach(table.getElementsByTagName("tr"), function(row,i){
if ( i % 2 == 1 )
dojo.html.addClass( row, "odd" );
});
});


jQuery:
jQuery("tr:nth-child(odd)").addClass("odd");
 
Frank Zammetti
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dojo too has class selector support, although I haven't played with it much... I can't give you the exact code off the top of my head, but you should be able to get pretty close in Dojo to what you write in jQuery.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic