Setting an element by class.
Reported by Larry Battle | January 14th, 2010 @ 10:53 PM
How do you select element by className?
Shouldn't it be $( ".className" )?
The only solution that I've found is to collect all the tagNames,
then loop through in search for the class.
Also, rightjs crashes when you call a method on a nonexistent
element.
$( "blockquote" ).tagName //Error: $( "blockquote" ) is null.
I think it should be better if somehow rightjs could fail safe.
Great work with rightjs. Keep it up!
Comments and changes to this ticket
-
MadRabbit January 14th, 2010 @ 11:03 PM
- State changed from new to invalid
Hey Larry,
for the dom navigation take a look at this page http://rightjs.org/tutorials/getting-started#navigation
it doesn't work like in jQ, it works like Prototype/Mootools$(id_only) - returns null or a reference to an element
$$(any_css_rule) - returns a list of matching elements on the page
So in your case you should call it like $$(".className").bla.bla.bla
as for $("blockquote").tagName it was not supposed to be like that, coz this function is also works as a check for an element existance, like
if ($('element-id')) bla_bla_bla();
meaning it is the original interface, it meant to return null if an element does not exist
btw: I've approved your membership on the googlegroup, you can post your questions over there.
Cheerz,
Nik
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
RightJS Core Tickets