jQuery get element by class
class, jquery
Solution
Is this supposed to be marked as jQuery or JavaScript?
jQuery:
var module = $("#clampjs"); // by id
var module = $(".clampjs"); // by classname
JavaScript:
var module = document.getElementById("clampjs"); // by id JS version
var module = document.getElementsByClassName("campjs"); // by class JS version
You might want to read up on jQuery: http://www.jquery.com if that is what you meant to do!
Problem
I'm currently using a script called clamp.js to cut some text, and it currently selects it by ID. I want to use it so it selects by class. The script is like this: ``` var module = document.getElementById("clampjs"); ``` How can I modify that line so it selects a certain "test" div class? thanks.