33 lines
659 B
JavaScript
33 lines
659 B
JavaScript
//Procedurális
|
|
const gomb=document.createElement('button');
|
|
gomb.textContent="JS gomb";
|
|
gomb.onclick=function(){
|
|
alert("Js gomb");
|
|
}
|
|
|
|
const jsgomb=document.getElementById('jsgomb');
|
|
jsgomb.appendChild(gomb);
|
|
|
|
|
|
//Deklaratív
|
|
|
|
const rgomb=React.createElement("button",{
|
|
onClick:function(){
|
|
alert("React gomb");
|
|
}
|
|
},"React gomb");
|
|
|
|
const kontener=React.createElement('div',
|
|
{
|
|
style:{
|
|
backgroundColor:"green",
|
|
width:"300px",
|
|
height:"200px"
|
|
}
|
|
},
|
|
rgomb,rgomb,rgomb,rgomb,rgomb,rgomb);
|
|
|
|
|
|
const root=ReactDOM.createRoot(document.getElementById('reactgomb'));
|
|
root.render(kontener);
|