The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

A Utility To Add CSS Classes To Elements That Match A Query

TODO: Pull subtitle into page object
Code
function addClassToQuery(className, query) {
  let els = document.querySelectorAll(query);
  for (let i = 0; i < els.length; i ++) {
    els[i].classList.add(className)
  }
}

Usage

Code
addClassToQuery("highlight", "widgets")

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

A Utility To Add CSS Classes To Elements That Match A Query

This function takes a class name and a query string. It
applies the former to any element on the page that matches
the later. There's nothing special about it other than it
prevents having to write the body of the function countless
times. 

-- code
-- javascript

function addClassToQuery(className, query) {
  let els = document.querySelectorAll(query);
  for (let i = 0; i < els.length; i ++) {
    els[i].classList.add(className)
  }
}

-- h3

Usage

-- code
-- javascript

addClassToQuery("highlight", "widgets")



-- blurb

-- categories
-- Utilities 
-- JavaScript 
-- CSS 

-- metadata
-- date: 2023-04-01 14:09:58
-- id: 2npswiwc
-- site: aws
-- type: post
-- status: published