那么我有3个按钮,这些必须只有一个类.fdm
所以每个按钮如何可能有不同的操作,只是调用类?如何为每个3个不同的按钮使用不同的动作?
我实际上使用,但像这样我必须设置ID到每个按钮。我不想要这个,我想设置一个类名并为所有按钮标识差异行为。
JS:
jQuery(function(){
$('#r').bind('click',function(){
$('#alvo').css('background','#ff0000');
})
$('#g').bind('click',function(){
$('#alvo').css('background','#155c00');
})
$('#b').bind('click',function(){
$('#alvo').css('background','#001eff');
})
})
HTM:
<div id="alvo" style="width:200px;height:200px;border:2px #000 solid;">
</div>
<button class="fdm" type="button" id="r">R</button>
<button class="fdm" type="button" id="g">G</button>
<button class="fdm" type="button" id="b">B</button>
就像我说的,我只是想用一个类名来这里更新了小提琴的所有按钮
什么是不使用'id'来做到这一点的原因?为什么你想让你的按钮只有一个'class'? – 2013-04-26 11:05:24
这和家庭作业形成高中,按钮的差异操作havin相同的类没有身份证。 – guihknx 2013-04-26 11:06:46