jquery javascript显示/隐藏切换删除内容
我想删除阶段内容(第一个标题-请参阅fiddle),只想在我的代码中包含以下内容: 展开-所有步骤jquery javascript显示/隐藏切换删除内容,javascript,jquery,html,Javascript,Jquery,Html,我想删除阶段内容(第一个标题-请参阅fiddle),只想在我的代码中包含以下内容: 展开-所有步骤 步骤1 步骤2 步骤3 上述内容应在代码中不包含阶段内容。但我不知道如何更改javascript,以便删除阶段内容,只处理步骤内容 或以下是代码: jQuery(".phaseContent").hide(); jQuery(".stepsContent").hide(); //toggle the componenet with phase level jQuery(".phaseH
- 步骤1
- 步骤2
- 步骤3
jQuery(".phaseContent").hide();
jQuery(".stepsContent").hide();
//toggle the componenet with phase level
jQuery(".phaseHeading .heading1").click(function () {
$(this).toggleClass("active");
var th = jQuery(this).parent();
jQuery(th).next(".phaseContent").slideToggle(500);
return false;
});
jQuery(".stepsHeading .heading1").click(function () {
$(this).toggleClass("active");
var th = jQuery(this).parent();
jQuery(th).next(".stepsContent").slideToggle(500);
return false;
});
//Expand and collapse toggle
$(".accordion-expand-all").click(function () {
var expandLink = $(this);
var contentAreas = $(expandLink).closest(".phaseContent").find(".stepsContent");
// Toggle the content area visibility
$(contentAreas).toggle();
// If the content area is now visible
if ($(contentAreas).is(':visible')) {
// Change it to the collapse text
$(expandLink).text('Collapse - all steps');
} else {
// Change it to the expand text
$(expandLink).text('Expand - all steps');
}
$(expandLink).closest(".phaseContent").find(".stepsHeading .heading1").toggleClass("active");
return false;
});
HTML
第一阶段
Lorem ipsum dolor sit amet,是一位杰出的献身者。拉奥里特前庭。
步骤1
Lorem ipsum dolor sit amet,是一位杰出的献身者。老街前庭。
步骤2
Lorem ipsum dolor sit amet,是一位杰出的献身者。前庭拉奥里特,弓形前庭拉奥里特。
步骤3
Lorem ipsum dolor sit amet,是一位杰出的献身者。前庭拉奥里特,弓形前庭拉奥里特。
我已经更新了您的,希望您得到解决方案
更改了javascript部分
jQuery(".phaseHeading .heading1").click(function () {
$(this).toggleClass("active");
var th = jQuery(this).parent();
jQuery(th).next(".phaseContent").slideToggle(500);
jQuery(".phaseContent1").hide();
jQuery(".phaseHeading").hide();
return false;
});
<div class="phaseContent1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet, nunc eget laoreet sagittis, quam.
</div>
更改了html部分
jQuery(".phaseHeading .heading1").click(function () {
$(this).toggleClass("active");
var th = jQuery(this).parent();
jQuery(th).next(".phaseContent").slideToggle(500);
jQuery(".phaseContent1").hide();
jQuery(".phaseHeading").hide();
return false;
});
<div class="phaseContent1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet, nunc eget laoreet sagittis, quam.
</div>
Lorem ipsum dolor sit amet,是一位杰出的献身者。拉奥里特前庭。
或者,您也可以从html和
jQuery(“.phaseContent1”).hide()中删除此已更改的div代码>来自已更改的js我更新您的小提琴。请检查这个
我从HTML中删除了阶段标题
,并在手风琴展开支架上方放置了一个Div
名称
你可以用这个
$(".phaseHeading .heading1").click(function () {
$(this).toggleClass("active");
var th = jQuery(this).parent();
$(th).next(".phaseContent").slideToggle(500);
$(".phaseContent1").hide();
$(".phaseHeading").hide();
return false;
});
在Div类中也做一些更改
<div class="Content1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet.
</div>
Lorem ipsum dolor sit amet,是一位杰出的献身者。老街前庭。
jQuery(“.phaseBack,.phaseContent”).remove()代码>为什么不直接从html中删除?请添加相关代码,假设链接在几个月后失效,人们如何理解您所做的更正。谢谢…但当我将其粘贴到我的项目中时,它不起作用…我在javascript的开头放了什么…只有脚本标记?是的,您需要在标记中编写。看看我更新的答案。哇!这个答案快速而完美!它很有魅力!谢谢@普吉·蒂普:等你得到了,你就可以了。:)谢谢你的尝试。虽然答案不是我想要的,但我感谢你抽出时间。
<div class="Content1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet.
</div>