Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
How do I make this javascript function work?

When a button is clicked, I want it to scroll to the h2 of the other component (but they're all on the same page). Getting an error here, how to make this work?

 <script setup>
 import { scroll } from "quasar";
 const { getScrollTarget, setVerticalScrollPosition } = scroll;

 function scrollToElement(el) {
 const el = h2;
 const target = getScrollTarget(el);
 const offset = el.offsetTop;
 const duration = 1000;
 setVerticalScrollPosition(target, offset, duration);
 }
</script>

<template>
<h1 class="q-mx-md text-weight-medium text-primary">
 </h1>
<q-btn
  class="bg-primary text-white q-mx-lg cursor-pointer"
  size="lg"
  @click="scrollToElement(el)"
>
/></q-btn>`

And this is the other component:

<template>
<section class="q-pt-md scroll">
<div class="row items-center relative-position">
  <h2 class="q-ml-md text-weight-medium">
    {{ title }}
  </h2>
</div>
</section>
</template>`
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!