I have a jQuery open and close button that reveals text upon click. My opportunity for improvement is that whenever I click a button, the others activate instead of just the one I want. I'm a little new to jQuery. Any help is appreciated. As you can see from the pic, a click on one button opens both when I only want that one clicked to open.
JS:
var toggler = $('.js_toggler'),
box = $('.customer-grid');
toggler.on('click', function(ev) {
ev.preventDefault;
if ( !toggler.data('active') ) {
// If toggler is not active
toggler
.addClass('is-active');
setTimeout(function() {
toggler
.data('active', '1');
box.addClass('is-active');
}, 100);
} else {
// If toggler is already active
box.removeClass('is-active');
toggler
.removeClass('is-active');
setTimeout(function() {
toggler
.removeData('active');
}, 100);
}
});
HTML/PHP:
<section class="procurement">
<p class="date">Period of Perfomrance: <?php echo esc_html( $date ); ?></p>
<p class="title"><?php echo esc_html( $heading ); ?></p>
<button class="toggler js_toggler">+</button>
<p class="date"><?php echo strtoupper( $unqiue_id ); ?></p>
<p class="special">Special Item Numbers:</p>
<div class="customer-grid">
<section class="number">
<p class="item"><?php echo esc_html( $special_item_one ); ?></p>
<p class="value"><?php echo esc_html( $special_item_one_value ); ?></p>
</section>
CSS:
.customer-grid {
display: none;
&.is-active {
display: block;
}
}
答案 0 :(得分:1)
删除变量g++ -l coupi main.cpp -I D:/Development/Trash/test -L D:/Development/Trash/test
C:\Users\N\AppData\Local\Temp\cc6287BE.o:main.cpp:(.text+0x16): undefined reference to `getFunction1[abi:cxx11]()' collect2.exe: error: ld returned 1 exit status
和toggler
,将选择器移至box
事件处理程序的开头,并使用click
,并使用一个相对的横向来获取相关的{ {1}}
this