Reputation: 261
I know jQuery although I need to use YUI to change the href of an anchor with a class name (which is why I can't use straight up JavaScript).
This is what I have in jQuery, what's the equivalent in YUI?
$("a.magic-link").prop("href", "http://www.magic.com");
Upvotes: 0
Views: 1091
Reputation: 680
Use setAttribute(). See http://yuilibrary.com/yui/docs/api/classes/Node.html#method_setAttribute for reference documentation.
If you're working with DOM nodes in YUI, you should definitely read the Node user guide, it has lots of examples to help you understand how the API works in general: http://yuilibrary.com/yui/docs/node/
Edit: Thanks, Juan! Please also see http://jsrosettastone.com, which maps jQuery methods to YUI methods. The DOM APIs are conceptually pretty similar, they just have different names for things.
Upvotes: 4