Importing jQuery in SvelteKit

184
March 13, 2022, at 9:20 PM

How do I import jQuery in SvelteKit (with TypeScript support)?

const jq = window.$ as one would do in Svelte runs into window is not defined.

Answer 1

You can just use import as syntax:

import * as $jq from 'jquery';

Or you can do like this

import { onMount } from 'svelte';
import js from 'jquery';
onMount(() => {
  window.jq = js;
});
Rent Charter Buses Company
READ ALSO
how to Use Metafiled in Jquery like using .html({{current_variant.metafields.my_fields.pack_size_m2_}}); but not working

how to Use Metafiled in Jquery like using .html({{current_variant.metafields.my_fields.pack_size_m2_}}); but not working

Hi there i want to know how to embbed Shopify Metafield in Jquery like in want to do this

142
Lightslider not working on the server but works locally on my machine

Lightslider not working on the server but works locally on my machine

apologies if this seems like a noob question but I've been struggling to get my slider work on the server just like it does locallyIts tough to find the exact problem as there are no error logs on the console

95
Nested append in javascript

Nested append in javascript

I want to wrap both select and button under one div <div class="row">I have the below code working but unable to wrap it

133
Is there a way to show an element if it has all of the classes matched from an array that is consistently having variables pushed in and out of it?

Is there a way to show an element if it has all of the classes matched from an array that is consistently having variables pushed in and out of it?

I'm creating a sorting program for DnD spells that sorts all 318 spells into 83 different categoriesI have multiple arrays storing all of the information, and I know how to check if an element has a class from an array

155