vs6262
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: <script type="text/babel"> //"use strict" //import React from 'react'; //import ReactDOM from 'react-dom'; // https://www.youtube.com/watch?v=BwAakF_VUV8 const strongStyle = { fontFamily:'Arial' } function tick(_id) { const element = ( <div key="k-1" id={_id} name="rrr"> <h1><strong style={strongStyle}>Hello</strong>, world!</h1> <h2>It is {new Date().toLocaleTimeString()}.</h2> <br /> </div> ); const el2 = React.cloneElement(element, {key: "k-2",id:_id+"_02", style: {left: 10, top: 150, position: 'absolute'}}); // highlight-next-line ReactDOM.render([element, el2], document.getElementById('root')); } setInterval('tick("pp")', 1000); function _color(){ document.getElementById("pp").style.color = "#ff00ff"; document.getElementById("pp_02").style.color = "#00ff00"; //document.getElementById("pp_02").parentNode.removeChild(document.getElementById("pp_02")); } setTimeout(_color,4000); </script> | а я уже такое замутил, главное проще делать стили с initial id, а потом всю динамику document.getElementById(" |