Reputation: 115
I'm working on a free template which has a featured Div...
www.subigya.com/test/durbarsquare
"In the Spotlight" is the featured div.
I have simple jQuery js in there to switch the images. How do I switch the heading &
related to each div in the switch. Right now, only the images switch and not the text.
The script used is feature.js and the stylesheet is style.css
Upvotes: 0
Views: 218
Reputation: 342635
From your script:
$("#spotlightright a").click(function(){
//these two assignments are fine, because "href" and "title" are both attributes of "a" tags
var largePath = $(this).attr("href");
var largeAlt = $(this).attr("title");
//these two are not, an "a" does not have "h2" and "p" attributes
var featureHead = $(this).attr("h2");
var featureText = $(this).attr("p");
Solution: Directly reference the elements containing the text you are trying to copy over, e.g.
var featureHead = $('h2#example').text();
var featureText = $('p#example').text();
Upvotes: 2