New to Jquery and trying to translate some code from Prototype
I am trying to 开发者_如何学Ctranslate this code from Prototype into the same thing in Jquery:
$("follow_form").update("<%= escape_javascript(render('users/unfollow')) %>")
$("followers").update('<%= "#{@user.followers.count} followers" %>')
I think you'd want:
$('#follow_form').html("<%= escape_javascript(render('users/unfollow')) %>");
$('#followers').html('<%= "#{@user.followers.count} followers" %>');
The Prototype "$" function is a short-cut to "document.getElementById()" (sort-of; it's a little more complicated on IE). For jQuery, you have to use a CSS-like selector syntax. Then, the ".update()" function in Prototype is for accessing "innerHTML" with some extra cleanup behavior, and jQuery's ".html()" is similar.
精彩评论