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

163
Views
Obtener múltiples valores de cadena de consulta hash en una matriz javascript

El propósito de este código es abrir dos pestañas diferentes donde una pestaña está anidada dentro de la pestaña principal. Cuando el usuario hace clic en un enlace que transmite valores hash de cadena de consulta como los siguientes

http://127.0.0.1:5500/products/virtual-machines.html#Get_Started#v-pills-02-tab

Necesito abrir ambas pestañas a la vez cuando se carga la página. Bootstrap 5 es el complemento utilizado para. Intenté usar el siguiente código.

 var hash = location.hash.split('?')[0]; console.log(hash); if (hash) { var triggerEl = document.querySelector("#" + hash + ''); triggerEl.click(); }

resultado

 #Get_Started#v-pills-02-tab

Necesito deslizarme en dos var

 Get_Started v-pills-02-tab
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su código de ejemplo se divide en un signo de interrogación (?), Que no existe en su hash.

Tal vez podría escribir su hash como una lista separada por comas, el primer elemento de la lista sería la identificación del elemento de la pestaña principal y el segundo elemento sería la identificación del elemento de la pestaña secundaria, etc.

 http://127.0.0.1:5500/products/virtual-machines.html#Get_Started,v-pills-02-tab

Luego analícelo, dividiéndolo en coma.

 // substring out the leading '#' // and convert the comma-separated items into an array var tabIds = location.hash.substring(1).split(','); if(tabIds) { var $tab = $('#' + tabIds[0]); // Ensure that the element exists before clicking it if($tab.length > 0) { $tab.click(); // Check for subsequent tab-ids if(tabIds.length > 1) { var $subTab = $('#' + tabIds[1]); if($subTab.length > 0) { $subTab.click(); } } } }

(Lo siento si eres alérgico a jQuery. No debería ser difícil traducirlo a Vanilla JS).

about 4 years ago · Juan Pablo Isaza Report
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!