JQuery lavalamp: select focus / highlight of an object within lavalamp when clicking hyperlinks outside of lavamalm

Hi, I hope someone can help me with the lavalamp jQuery problem.

I have the following - a menu bar using lavalamp. - the div where the content is loaded when the link is clicked in the menu bar - in my content div I have links that link to the same pages as in the menu bar

The menu bar itself looks and works great. However, I wan't to be able to focus on / highlight the corresponding menu item "Menu Option" when the user clicks on one of the links in my contents.

Eg

<div><ul class="lavalamp">
  <li><a href="Item 1.html">item 1</a></li>
  <li><a href="Item 2.html">item 2</a></li>
  <li><a href="Item 3.html">item 3</a></li>
 </div>

<div id="dynamic-content">
   <a href="Item3.html">Item 3.html</a>
</div>

When the user clicks on element 3 in the dynamic content div, the selection on lavalamp should change.

Does anyone have any experience?

thank

+3
3

, jQuery lavaLamp . , SimpleCoder. , :

    $(function() {
        var loc = window.location.href;
        var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length);

         $('.lavalamp a, #dynamic-content a').each(function(){
            if ($(this).attr('href') == filename){
               $(this).parent().addClass('current');
            }
         });

        $(".lavalamp").lavaLamp({
            fx: "backout",
            speed: 700
         })
    });
+2

lavalamp, lavalamp lavaLamp(), startItem:

$('#myLavalamp').lavaLamp({startItem: 4});

, . , , lavalamp .

+2
    $(function() {
    var loc = window.location.href;
    var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length);

     $('#2 a, #dynamic-content a').each(function(){
        if ($(this).attr('href').indexOf(filename)>-1){
           $(this).parent().addClass('current');
        }
     });

    $("#2").lavaLamp({
        fx: "backout",
        speed: 700
     })
});
-1

Source: https://habr.com/ru/post/1756085/


All Articles