javascript - One CSS class with jQuery Click Function Exception -
.box { width:45px; height:45px; line-height:45px; border:1px solid #808080; border-radius:8px; text-align:center; color:#000; font-weight:bold; font-size:24px; font-family:arial, helvetica, sans-serif; cursor:context-menu; }
i have css class called .box , have php loop creating div layers referring class this:
<div class="box">content</div>
i have jquery click function listens clicks on div layer class="box"
this:
$(".box").click(function(){
my question within loop there div layers still need styled .box
class not want click function apply to. way have solved creating clone of .box
, calling .box2
, seeing there not .box2
click event jquery click function applies .box
class div.
however, wondering if there better way , stick 1 class rather two, code , everytime want change style, have replicate twice. there maybe way add parameters , make class="box active"
?
hope makes sense.
you can use active
like:-
$(".box.active").click(function(){
this bind click event elements has both classes (class="box active"
).
Comments
Post a Comment