Is there something wrong with this code?
For some reason, the 'continue' class isn't getting added (last line).
function getBlogs(element, url, limit, feed){
jQuery(element).load(url+ ' .xg_blog_list .xg_module_body:lt('+ limit+ ')', function(){
jQuery(this).prepend("<a class='home-rss' href='"+ feed+ "'></a>");
jQuery(this).append("<a class='view-all-blogs' href='"+ url+"'>View More »</a>");
jQuery(".xg_module_body .postbody").last("a").each(function(index) {
addClass("continue");
});
});
}
Relevant html:
<div class="postbody">
<p><a href="link"><img src="image"></a></p>
<p>titl开发者_如何学Pythone</p>
<a href="link">Continue</a>
</div>
You can either call:
jQuery(".xg_module_body .postbody").last("a").each(function() {
$(this).addClass("continue");
});
Or:
jQuery(".xg_module_body .postbody").last("a").addClass("continue");
You have to call .addClass
on an object, otherwise what would it add the class to?
$(this).addClass('continue');
精彩评论