简单的javascript“功能”面板

时间:2009-03-23 14:08:42

标签: javascript jquery

我正在开发一个免费的模板,它有一个特色Div ...

www.subigya.com/test/durbarsquare

“在聚光灯下”是特色div。

我有简单的jQuery js来切换图像。如何切换标题&

与交换机中的每个div相关。现在,只有图像切换而不是文本。

使用的脚本是feature.js,样式表是style.css

1 个答案:

答案 0 :(得分:2)

从你的剧本:

$("#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");

解决方案:直接引用包含您要复制的文本的元素,例如

var featureHead = $('h2#example').text();
var featureText = $('p#example').text();