jessquery
Version:
Modern JavaScript is pretty good, but typing document.querySelector() is a pain. This is a tiny library that makes DOM manipulation easy. jQuery is around 80kb (30kb gzipped), while this is only around 8kb (3.5kb gzipped). Lots of JSDoc comments so it's s
37 lines (32 loc) • 967 B
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div class="display">hi</div>
<button class="location">click me</button>
<script type="module">
import { $, promisify } from "../index.js"
const getLocation = promisify(
(resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject)
},
10000,
{ fnName: "getLocation" }
)
async function getCoordsText() {
const pos = await getLocation()
return `Lat: ${pos.coords.latitude}, Lng: ${pos.coords.longitude}`
}
$(".location").on("click", () => {
$(".display")
.text("Fetching location...")
.text(getCoordsText())
.css("color", "blue")
})
</script>
</body>
</html>