首先,我检查了大部分与此相关的答案,但我没有找到任何对我有用的答案。
我想在点击时显示/隐藏p标签。目前只适用于这样的悬停:
<aside>
<div>
<ul>
<li class="asideMenu"> <a href="#">Click to Open 1 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
<li class="asideMenu"><a href="#"> Click to Open 2 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
<li class="asideMenu"><a href="#"> Click to open 3 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
</ul>
</div>
</aside>
和jQuery:
$('div ul li p').hide().removeClass('asideMenu');
$('div ul li').hover(
function () {
$('p', this).stop().slideDown(500);
},
function() {
$('p', this).stop().slideUp(500);
}
);
我尝试将'.hover'更改为'.click',也包括功能之前的点击。('click',function ...,但我没有成功。
你能告诉我如何制作与我现在完全相同的效果,但是“点击”,而不是“悬停”吗?
提前致谢!
答案 0 :(得分:0)
for (int i = 0; i < 30; i+=2)
{
Brush snizovaniViditelnosti = new SolidBrush(Color.FromArgb(0+i*8, 0+i*8,0+i*8));
g.DrawString("+1", fontPridaniMaterialu, snizovaniViditelnosti, MousePosition.X, MousePosition.Y - i);
System.Threading.Thread.Sleep(30);
//ImageAnimator.Animate()
Timer d = new Timer();
d.Interval = 55;
Refresh();
}
只有一个函数作为参数,所以您可以这样使用:
如果你想总是只显示被点击的元素并隐藏之前打开过的那么做,否则请参阅代码中的注释
on.click()
$('div ul li p').hide().removeClass('asideMenu');
$('div ul li').on('click', function() {
$('.subAside').slideUp(); // remove this line to hide/show only on click
$(this).children('.subAside').slideToggle();
});
答案 1 :(得分:0)
试试这段代码:
$('div ul li p').hide().removeClass('asideMenu');
$('div ul li').on("click", function() {
$(this).find("p").slideToggle();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<aside>
<div>
<ul>
<li class="asideMenu"> <a href="#">Click to Open 1 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
<li class="asideMenu"><a href="#"> Click to Open 2 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
<li class="asideMenu"><a href="#"> Click to open 3 </a>
<p class="subAside"> Uneasy barton seeing remark happen his has. Am possible offering at contempt mr distance stronger an. </p>
</li>
</ul>
</div>
</aside>