jquery - Setting CSS classes as a variable in Javascript for later use? -
i want know if it's possible set css class e.g. ".duck" variable in javascript using jquery e.g. var duck = $(".duck");
i've done "body" tag , css id's doesn't seem work kind of class.
i want set variable later use, have id "#frog" set "var frog = $("#frog");" in javascript can type
frog.moveto(0); frog.speed(0.3); frog.autobounceoff(true);
but duck class still have use
$(".duck").moveto(270); $(".duck").speed(0.65); $(".duck").oncollision(function(otherobj){
is possible set classes variable?
there nothing related css here.
duck
html class..duck
class selector.$(".duck")
function call returns jquery object (containing dom elements, in document, members of class @ time function called).
you can store return value of function call in variable.
a common convention store jquery objects in variables names starting $
.
var $duck = $(".duck");
Comments
Post a Comment