【发布时间】:2011-04-12 09:22:06
【问题描述】:
我有这个用 jQuery 制作的脚本,我用它来在我的页面上显示/隐藏 div。 我真的需要它纯粹用 JavaScript 制作,但我不知道该怎么做。 谁能帮帮我??? 我想我需要一个转换器什么的。 . .
$("#optiuni").children().click(function(){
$("#" + $(this).attr('name')).show().siblings().hide();
/*Gives the link-activ class to the link that i clicked an link-inactive to all others*/
$(this).attr('class','link-activ').siblings().attr('class','link-neactiv');
});
/*this makes shure that the first option from my list is active incarcarea paginii*/
$("#optiuni li.prima").children().click();
示例标记:
<div id="lista">
<ul id="optiuni">
<li id="titlu-lista-p"> <p class="listname-t">Past Events </p></li>
<li name="opt-1" class="prima"><a href="#"><p class="listdata">28.02.2011</p><p class="listname">TABU Oscar Party</p> </a></li>
<li name="opt-2" ><a href="#"><p class="listdata">24.03.2011</p><p class="listname">Cheese & Wine</p></a></li>
<li name="opt-8"><a href="#"><p class="listdata">08.04.2011</p><p class="listname">George Baicea</p></a></li>
</ul>
</div>
<div class="centru">
<div id="continut" >
<div id="opt-2" class="galerie" style="background-color: black;">
<iframe id="gal" src="cheese/index.html"></iframe>
</div>
<div id="opt-1" class="galerie" style="background-color: black;">
<iframe src="tabu/index.html"></iframe>
</div>
<div id="opt-8" class="galerie" style="background-color: blue;">
<iframe src="no-ev/index.html"></iframe>
</div>
</div>
</div>
【问题讨论】:
-
您需要 Java 还是 Javascript?这是两个不同的东西=)
-
jquery 是 javascript,有什么问题?
-
为什么不能使用jQuery?它可以为您节省大量工作......
-
您至少可以表现出一些努力并为自己尝试一下。很高兴纠正错误,但我们不是免费的编码服务!复制和粘贴解决方案您将一无所获。
-
你必须考虑函数在做什么,并考虑使用“纯”JavaScript 的相应解决方案。例如。
element.style.display = 'none'为hide()。或者看看这些函数的 jQuery 源代码。
标签: javascript jquery transform