I have this code set up and everything works except the last line for some reason.
function getBlogs(element, url, limit, feed){
jQuery(element).load(url+ ' .blog_list .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>");
// ** The following line isn't working: **
jQuery(".tab-container .module_body .postbody").last("a").addClass("continue-link");
});
}
var blogUrl = 'http://mysite.com/blog/list';
var feedUrl = '/profiles/blog/feed';
getBlogs('#all-blogs', blogUrl, 5, feedUrl);
getBlogs('#feat-blogs', blogUrl+ '?tag=featured', 5, feedUrl+ '?promoted=1');
jQuery(".tab_content").hide();
jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
jQuery(".tab_content:first").show(); //Show first tab content
//On Click Event
jQuery("ul.tabs li").click(function() {
jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
jQuery(this).addClass("active"); //Add "active" class to selected tab
jQuery(".tab_content").hide(); //Hide all tab content
var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
jQuery(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
jQuery("#column1").append("<ul class='tabs'><li class='news'><a href='#all-blogs'>News</a></li><li class='featured-blogs'><a href='#feat-blogs'>Featured Blogs</a></li></ul><div class='tab_container'><div id='all-blogs' class='tab_content'></div><div id='feat-blogs' class='tab_content'></div></div>");
Specifically, the class doesn’t get added with this line:
jQuery(".tab-container .module_body .postbody").last("a").addClass("continue-link");
Is there anything I’m missing?
-edit-
Here’s the html affected by it:
<div class="postbody">
<p><a href="link" target="_self"><img width="633" src="image"></a></p>
<p>Title</p>
<a href="link">Continue</a>
</div>
Try:
From the docs, the
lastmethod doesn’t take a selector.Also not that in some places, you have used the class name
tab_containerand in others, you have usedtab-container. That won’t help.