Answer the question
In order to leave comments, you need to log in
Can't figure out how to change the script?
Actually such a thing. There is a script that works on the principle of tabs (it was written to me), when you select one of the performers in this menu, the content in the right block (the largest) changes. The structure of this whole case is something like this:
//это непосредственно часть меню
<p class="letters">A</p>
<hr style="border:1px solid #212121; margin:0;">
<nav class="menu2">
<ul class="second-menu">
<li><a href="#marman" data-nav>Marilyn Manson</a></li>
<li><a href="#metal" data-nav>Metallica</a></li>
<li><a href="#muse" data-nav class="active">Muse</a></li>
</ul>
</nav>
//собственно сам один из блоков, при нажатии по ссылке из меню с ссылкой "#muse" открывается одноименный div
в блоке с контентом
<div class="col-xs-7">
<section class="href-target">
</section>
<div class="content">
<div id="muse">
<h1 style="position:absolute; padding:0;color:white;margin:7px 0 0 275px;">Muse</h1>
<img src="img/musesongs.jpg" class="img-responsive">
<h2 class="albums123">Альбомы</h2>
<div class="first column">
<figure class="imghvr-fade">
<img src="img/showbiz.jpg">
<figcaption>
<p class="namealb">Showbiz</p>
<p class="date1">Дата выхода: 09.09.1999</p>
<p class="label1">Лейбл: Warner Bros.</p>
</figcaption>
<a href="#"></a>
</figure>
<p class="textunder">Showbiz</p>
</div>
$(document).ready(function(){
var menuNavigator = {
frame: document.querySelector('.href-target'),
navigate: function(frameId) {
var frm = document.querySelector(frameId);
if(frm == null) throw new Exception('Frame '+frameId+' doen\'t exists!');
this.setFrameContent(frm.innerHTML);
},
setFrameContent: function(txt) {
this.frame.innerHTML = txt;
}
};
$('.second-menu a').on('click', function(event) {
event.preventDefault();
var frmId = new URL(this.href).hash;
menuNavigator.navigate(frmId);
$('.second-menu a.active').removeClass('active');
$(this).addClass('active');
});
menuNavigator.navigate('#muse');
});
Answer the question
In order to leave comments, you need to log in
I didn’t quite understand what you need, but I dare to suggest: replace '.second-menu a' with the object that should be clicked, and add the attribute that we should go to.
For example, if you just inserted an image instead of a link, then it should be something like:
...
<ul class="second-menu">
<li><img src="img/img1.jpg" data-nav data-href="#marman"></li>
<li><img src="img/img2.jpg" data-nav data-href="#metal"></li>
<li><img src="img/img3.jpg" data-nav data-href="#muse"></li>
</ul>
...
$('.second-menu img').on('click', function(event) {
event.preventDefault();
/* Это оставим для ссылок
var frmId = new URL(this.href).hash;
*/
// Получим, куда нам идти
var frmId = $(this).data('href');
menuNavigator.navigate(frmId);
/* И это тоже для ссылок
$('.second-menu a.active').removeClass('active');
$(this).addClass('active');
*/
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question