Hello! Can you help? I have a calculator on javascript. Do I need to create my tag, which added my calculator when I added it?
- fourcalculator tag? I don't seem to know anything about web technologies. - Dan the Hat
- onealso can not imagine what was going on in principle. - Igor
- oneDescribe in more detail what you need to do. - websnap
- oneThis is something like a React component already) - lampa
- 3If you just to expand the horizons, then here's an experimental technology for you - ( learn.javascript.ru/webcomponent-core ). If for work, here's a more useful link for you to create your own applications - ( learn.javascript.ru/prototypes ). - Ilya
|
1 answer
Like that:
$(document).ready(function() { $('calculator').show(function() { myCalc.init(this); }) }); var myCalc = new Object(); myCalc.params = { 'a': 1, 'b': 2 }; myCalc.init = function(container) { layout = "<div id='calc'><input type='text' id='in'><br>"; layout += "<span id='out'><br>"; layout += "<button id='plus'>+</button> <button id='minus'>-</button> <button id='eq'>=</button></div>"; $(container).append(layout); } calculator { display: block; width: 200px; height: 100px; padding: 10px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <calculator> my calc </calculator> |