我正在尝试删除类'fa-minus',除非它的元素部分被触发。其他一切都很好,但是,我无法定位所有具有“fa-minus”类的跨度,而不会影响被点击的下拉列表。感谢任何帮助。谢谢。
HTML
<div id="accordion">
<h3 class="accordion-trigger">Do you lease to individuals and corporations?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>Cornerstone leases to all people who are in need of short term furnished housing: business travelers, human resource/relocation departments, government personnel, and vacation travelers. We also serve the insurance industry for displaced home owners in need of temporary furnished housing.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">Are you the same as an extended stay hotel?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>No. We offer a full sized furnished apartment that is much larger than a hotel room and is fully equipped with all the comforts of home.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">Is there a minimum stay?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>Yes, most locations have a 30 day minimum length of stay.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">Can I bring my family pet?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>Yes you can, as we offer pet friendly properties in every city and area. Most properties have a pet weight limit and breed restrictions, and require an additional pet deposit and/or pet fee.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">How do I Pay?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>We accept Visa, MasterCard and American Express. For companies paying by check, a major credit card is required on file.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">Is there a fee for internet access?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>No, our apartments include high speed internet and Wi-Fi service at no additional charge.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">Is phone service included?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>We have found that most of our guest use their cell phones and do not require land lines. For additional questions please speak with a Cornerstone representative.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">How do I get the keys to my apartment and check in?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>Once your reservation is confirmed we will send you your address and easy directions from the airport or major highway. Typically guest should plan to arrive during office hours. Late check in can be arranged but may require an additional fee.</p>
</div>
<div class="hr1"></div>
<h3 class="accordion-trigger">What are the check in and check out times?<span class="fa fa-fw fa-plus icons accordion-icon"></span></h3>
<div class="accordion-content-container">
<p>Typically check in is at 2pm and check out is at 11am.</p>
</div>
</div> <!-- accordion end -->
JS
$(document).ready(function($) {
$('#accordion').find('.accordion-trigger').click(function(){
//Expand or collapse this panel
$(this).next().slideToggle('fast');
$(this).find('span').toggleClass('fa-minus');
//Hide the other panels
$(".accordion-content- container").not($(this).next()).slideUp('fast');
// remove classes 'fa-minus' unless its part of the accordion being triggered
});
});
答案 0 :(得分:2)
这样的事情应该让你开始:
$('.accordion-trigger').click
注意:
(1)您可以使用$('#accordion').find('.accordion-trigger').click
代替$(".accordion-content-container").hide();
(2)我在javascript中添加了[9 payments], [Delay Tax return], [Delay Tax return]
,最初隐藏了所有内容div。
答案 1 :(得分:1)
谢谢你的帮助。我最终将手风琴的每个部分都包装在一个容器中,以便更好地利用可用的JQuery方法。我追加了.parent()。find('span')。removeClass('fa-minus'); to $(“。accordion-content-container”)。not($(this).next())。slideUp('fast')。这就是我首先要做的事情,我只是没有仔细阅读文档,并试图以错误的方式使用'parent()'。
这行代码已经是我需要移除'fa-minus'类的地方了,我只是很难通过'fa-minus'类来遍历DOM到span。 / p>
在'acccordion-container'div中包装手风琴的每个部分,可以使用parent()。这种代码执行时这样:
。$( “手风琴内容容器”)不($(本)的.next())效果基本show( '快');
我可以将DOM遍历到最近的父级,即.accordion(但现在是.accordion-container)。
最后,在'accordion-content-container'被关闭的情况下,'parent()'回顾'accordion-container',然后找到driver.get("your-application-URL")
time.sleep(3)
window_before = driver.window_handles[0]
windowHandlesAllBefore = driver.window_handles
linkElements = driver.find_elements_by_css_selector("[onclick='javascript:grv(']")
for aLink in linkElements:
aLink.click()
time.sleep(3)
newWindowHandle = list(set(driver.window_handles) - set(windowHandlesAllBefore))[0]
print(newWindowHandle)
driver.switch_to.window(newWindowHandle)
print(driver.current_url)
driver.close()
driver.switch_to.window(window_before)
并删除类'fa-minus ”。
我希望像往常一样,每天我都在学习新的东西。