mardi 21 avril 2015

i need to hide a dynamically created div using dynamically created button using jquery constructor function

<!DOCTYPE html>
<html>
    <head>
    <script src='jquery-1.11.2.js' type="text/javascript"></script>
       <div id='divn'></div>
              <script>

     function createDomControls(id,appendToId)
                {   this.id=id;
                    this.appendToId=appendToId;
              this.divTag=function(divId,className,style,appendToId)
                 {
                     //var divId = "div" + Math.floor((Math.random() * 100000) + 1);

                         $('<div/>', {
                                     id: divId,
                                    style: style,
                              class:className 
                    }).appendTo('#' + appendToId);


         }
         this.buttonTag=function(type,id,value,appendToId)
         {
            $('<input/>',{
                type:type,
                id:id,
                value:value,
                onclick:onclick function(){
                $('#div1').hide();
            }

         });

        }

        }

var domControls=new createDomControls('divm','divn'); var div=domControls.divTag('div1','cls','background:pink;width:500px;height:670px;padding:12px;margin:0px;','divn'); var btn=domControls.buttonTag('button','btn1','+','div1');

               </script>
</head>




Aucun commentaire:

Enregistrer un commentaire