Пользовательский код JQuery для кнопки, открывающей определенный раздел c веб-страницы Divi Wordpress на мобильном устройстве - PullRequest
0 голосов
/ 03 августа 2020

Я новичок в JQuery и Divi. На веб-странице A я использую кнопку, которая перенаправляет пользователя на веб-страницу B со структурой переключения-скрытия-показа с различными вкладками, которые я создал с помощью учебника Divi https://balonline.dk/hide-and-reveal-section-row-or-module/ и некоторая помощь от службы поддержки Divi.

Теперь, когда пользователь нажимает кнопку на веб-странице A , пользователь должен быть перенаправлен на веб-страница B и в зависимости от того, на какую кнопку нажал пользователь, должна открыться соответствующая часть раздела скрытия и раскрытия. Прямо сейчас я добавил кнопку как пользовательскую CSS на веб-страницу A , используя:

.dt-blurb .dt-button {
opacity: 0;
transition: opacity 400ms linear 0ms;
}
.dt-blurb:hover .dt-button {
opacity: 1;
}

И эта кнопка имеет тело:

<p> TEXT <br /> Colour | Tint (Jetness better)</p>
<p><a href="http://dummy.wp-install.com/page/#section/" class="et_pb_button blurb-button dt-button"> Click here</a></p>

Скрыть и показать раздел на веб-странице B создается с помощью кода JQuery ниже:

<script type=”text/javascript”>
jQuery(document).ready(function() {
// Hide the div
// jQuery(‘#reveal’).hide();
jQuery(‘.rv_button1’).click(function(e){
e.preventDefault();
jQuery(“#reveal1”).slideToggle();
// Hide the div
jQuery(‘#reveal2’).hide();
jQuery(‘#reveal3’).hide();
jQuery(‘#reveal4’).hide();
jQuery(‘#reveal5’).hide();
jQuery(‘.rv_button1’).toggleClass(‘opened closed’);
});
});
</script>

<script type=”text/javascript”>
jQuery(document).ready(function() {
// Hide the div
jQuery(‘#reveal2’).hide();
jQuery(‘.rv_button2’).click(function(e){
e.preventDefault();
jQuery(“#reveal2”).slideToggle();
// Hide the div
jQuery(‘#reveal1’).hide();
jQuery(‘#reveal3’).hide();
jQuery(‘#reveal4’).hide();
jQuery(‘#reveal5’).hide();
jQuery(‘.rv_button2’).toggleClass(‘opened closed’);
});
});
</script>

<script type=”text/javascript”>
jQuery(document).ready(function() {
// Hide the div
jQuery(‘#reveal3’).hide();
jQuery(‘.rv_button3’).click(function(e){
e.preventDefault();
jQuery(“#reveal3”).slideToggle();
// Hide the div
jQuery(‘#reveal1’).hide();
jQuery(‘#reveal2’).hide();
jQuery(‘#reveal4’).hide();
jQuery(‘#reveal5’).hide();
jQuery(‘.rv_button3’).toggleClass(‘opened closed’);
});
});
</script>

<script type=”text/javascript”>
jQuery(document).ready(function() {
// Hide the div
jQuery(‘#reveal4’).hide();
jQuery(‘.rv_button4’).click(function(e){
e.preventDefault();
jQuery(“#reveal4”).slideToggle();
// Hide the div
jQuery(‘#reveal1’).hide();
jQuery(‘#reveal2’).hide();
jQuery(‘#reveal3’).hide();
jQuery(‘#reveal5’).hide();
jQuery(‘.rv_button4’).toggleClass(‘opened closed’);
});
});
</script>

<script type=”text/javascript”>
jQuery(document).ready(function() {
// Hide the div
jQuery(‘#reveal5’).hide();
jQuery(‘.rv_button5’).click(function(e){
e.preventDefault();
jQuery(“#reveal5”).slideToggle();
// Hide the div
jQuery(‘#reveal1’).hide();
jQuery(‘#reveal2’).hide();
jQuery(‘#reveal3’).hide();
jQuery(‘#reveal4’).hide();
jQuery(‘.rv_button5’).toggleClass(‘opened closed’);
});
});
</script>

Текущий результат связывания этих двух страниц заключается в том, что я могу перенаправить с веб-страница A - веб-страница B , но я не могу открыть определенный раздел c структуры скрытия-показа, так как по умолчанию все разделы закрываются. По словам службы поддержки Divi, это должно быть легко исправить с помощью JQuery, но я не знаю, как это сделать.

...