Need help with HTML and JavaScript

snorri

Newbie
Joined
Jun 26, 2014
Messages
37
Reaction score
52
Hi guys!

I need help with this code below. I got 6 blocks like that, and every time someone clicks on this image, it expands and shows the post and I also want it to scroll the page back to the top. But I'm not sure if that's possible. Link to the addon demo https://crocoblock.com/widgets/tabs/

I can't add any id to the image itself.

HTML:
<div id="iCanOnlyAddIdHere" class="jet-tabs__control jet-tabs__control-icon-left elementor-menu-anchor active-tab" data-tab="1" tabindex="1181" role="tab" aria-controls="jet-tabs-content-1181" aria-expanded="true" data-template-id="731">
    <div class="jet-tabs__control-inner">
        <img class="jet-tabs__label-image" src="https://demo.com/wp-content/uploads/2020/07/oksf.png" alt="">
    </div>
</div>

I'm like 51% sure that it can't be done, but I'd like to hear it from someone with experience in HTML/JS.

I appreciate any help.
 
It's very vague without the live example in front of me, but you can add something like this to your code:
JavaScript:
$(".jet-tabs__control").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

Keep in mind this uses jQuery. Make sure you have that before you test.
 
It's very vague without the live example in front of me, but you can add something like this to your code:
JavaScript:
$(".jet-tabs__control").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

Keep in mind this uses jQuery. Make sure you have that before you test.

Thanks for the replay!

I tried a method like this one, it didn't work. jQuery works fine. Maybe I can send you the URL so you can check it live?
 
I can take a quick look, but if it's complex I recommend you hire a freelancer.
 
Nearly anything can be done, but it's unclear what you are trying to achieve. You do or do not want the image to expand when clicked on? If you do want that, then why scroll to the top of the page?
 
Back
Top