Migrating from jQuery to Prototype
I'm starting to write code using Prototype coming from a jQuery background. 开发者_如何学JAVAIs there any chart that shows the prototype equivalent method to use in place of specific jQuery methods?
More specifically, I'm looking for a $('#my-id').prepend('some stuff') equivalent in prototype?
Other folks here will know much more about prototypejs than I, but here's a prototypejs/javascript hybrid. Who knows, maybe this is how its done.
var $elem = $('my-id');
var newNode = document.createTextNode('some text')
$elem.insertBefore(newNode, $elem.firstChild);
Something tells me that prototypejs must have some easier way of creating text nodes, and/or prepending them.
EDIT:
I think I figured it out:
var $elem = $('my-id'); // Get element with ID 'my-id'
$elem.insert({top:'someText'} ); // insert 'someText' at top position in $elem
http://www.prototypejs.org/api/element/insert
精彩评论