transform this to vanilla js…
- User
transform this to vanilla js
document.querySelector(“#container”).addEventListener(“mousemove”, function(e) { parallaxIt(e, “.slide”, -100); parallaxIt(e, “img”, -30); });
- Assistant
document.querySelector("#container").addEventListener("mousemove", function(e) { parallaxIt(e, ".slide", -100); parallaxIt(e, "img", -30); });
- User
check if page has duplicated css ids
- Assistant
To check if a web page has duplicated CSS IDs, you can use the following Vanilla JavaScript code:
function checkDuplicateIds() { var ids = {}; var duplicatedIds = []; // Get all elements with an ID attribute var elementsWithIds = document.querySelectorAll("[id]"); // Loop through each element elementsWithIds.forEach(function(element) { var id = element.id; // Check if the ID has already been found if (ids[id]) { duplicatedIds.push(id); } else { ids[id] = true; } }); // Return the duplicated IDs, if any return duplicatedIds; } // Usage var duplicatedIds = checkDuplicateIds(); if (duplicatedIds.length > 0) { console.log("The following IDs are duplicated: " + duplicatedIds.join(", ")); } else { console.log("No duplicated IDs found."); }This code defines a function
checkDuplicateIdsthat checks for duplicated IDs in the web page. It uses thequerySelectorAllmethod to retrieve all elements with an ID attribute, and then loops through each element to check if the ID has already been found. If a duplicated ID is found, it is added to an arrayduplicatedIds. Finally, the code logs the duplicated IDs if any are found.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.