2013-10-30 34 views
-1

好的我有下面的代码,按钮,当我按下它,我创建divs,我想当dblclick 上的div输入类型的颜色显示,并改变div的颜色,但没有button.The问题是我tryed与变化的选择,但提交它单曲现在working.Here是代码htm5输入类型的颜色和jquery

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title></title> 
     <style> 
      #toolbar{ 
       width:600px;height: 100px;border: 3px solid; 
       position: absolute;left: 350px; 
      } 
      #buttons{ 
       position: relative;top:15px;left:150px; 
      } 
      #ButtonElement{ 
       width: 600px;border: 3px solid;position: absolute;top:200px; 
       height: 600px; 
      } 
      #TextElement{ 
       width: 600px;border: 3px solid;position: absolute;top:200px;left:700px; 
       height: 600px; 
      } 

     </style> 
    </head> 
    <body> 
     <div id="toolbar"> 
      <div id="buttons"> 
      <button id="Button">Create Element Button</button> 
      <button id="Text">Create Element Text</button></div> 
     </div> 
     <div id="ButtonElement"><h2>Elements Button</h2></div> 
     <div id="TextElement"><h2>Elements Text</h2></div> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> 
</script> 
     <script> 
     // function Toolbar(){ 
      //  this.render=function(){ 
      //   $('body').append("<div id='toolbar'></div>"); 
      //  }; 
      //  this.init=function(){ 
      //   $("#toolbar").append("<div id='buttons'></div>"); 
      //  }; 
      //  this.createButton=function(){ 

      //  }; 
      // } 
      var Colors=[]; 
      var count=0; 
     function Button(count){ 
    this.background=null; 
    this.count=count; 
    this.render=function(){ 

     $("#ButtonElement").append("<div id=div" + this.count +">Nqkakav Tekst</div>"); 
    }; 

} 

Button.prototype.setBackground=function(background){ 
    this.background=background; 
}; 
Button.prototype.getBackground=function(){ 
    return this.background; 
}; 

$("#Button").click(function(){ 
    count++; 
    var b=new Button(count); 
    b.render(); 
    $("#div"+ count).dblclick(function(){ 
    var diva=this; 
    $(this).append("<span id='colorchange'><input type='color' id='color' name='favcolor'></span>"); 
    $("#color").change(function(){ 

    var value=$("#color").val(); 
    cssChange(diva,value); 
    });enter code here 

}); 
}); 


      </script> 
    </body> 
</html> 

so I just want when click on some of the divs colorpicker to show and when i click on some color to change the background of the div. 

回答

2

可以使用Active:当格是活动使用。点击

+0

可以您向我展示代码 – dganchev

+0

#ButtonElement:active { width:600px; border:3px solid; position:absolute; top:200px; height:600px; } – mortiped