theRealAlexz switching to to other cases
by tyckr
HTML
<h5 class="questioncard">Read about <a class="read" href="#div1">books</a> or <a class="read" href="#div2">ebooks</a>?</h5>
<div class="readmore" id="readmore"></div>
JavaScript
jQuery(function($){
var books, ebooks = false;
$(".read").click(function() {
var text = $(this).text();
if(text === "books")
books = true;
else if(text === "ebooks")
ebooks = true;
if(books && ebooks) {
$(".readmore").html("Do you want to distribute?");
} else if(books) {
$(".readmore").html("Read more about <a id='showdiv2' href='#div2'>ebooks?</a>");
} else if(ebooks) {
$(".readmore").html("Read more about <a id='showdiv1' href='#div1'>books?</a>");
}
});
});