function create() { var num = 15; for (var i = 0; i < num; i++) { var div = document.createElement('div'); div.className = "ava"; div.onclick = function(i) { return function() { alert(i); } }(i); div.innerHTML = '<strong>' + i + '</strong>'; div.setAttribute("id", i); calb.insertBefore(div, calb.childen); test(i); } } .ava { opacity: 0; cursor: pointer; text-align: center; float: left; width: 65px; margin: 10px; padding: 15px; border: 1px solid #d6e9c6; border-radius: 4px; color: #3c765f; background-color: #C7F7B7; transition: 0.3s; } .ava:hover { transform: scale(1.1); text-align: center; } <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> function test(num) { $('#' + num).animate({ opacity: '1' }, 5000); } </script> </head> <body> <div id="calb"></div> <script> create(); </script> </body> </html> The following codes are available:
CSS:
.ava { opacity:0; cursor: pointer; text-align: center; float: left; font-size: 18px; width: 65px; margin: 10px; padding: 15px; border: 1px solid #d6e9c6; border-radius: 4px; color: #3c765f; background-color: #C7F7B7; transition: 0.3s; } .ava:hover { transform: scale(1.1); text-align: center; } Javascript:
function create() { var num = 15; for(var i = 0; i < num; i++) { var div = document.createElement('div'); div.className = "ava"; div.onclick = function(i) { return function() { alert(i); }}(i); div.innerHTML = '<strong>' + i + '</strong>'; div.setAttribute("id", i); calb.insertBefore(div, calb.childen); test(i); } } Jquery:
function test (num) { $('#'+num).animate({opacity:'1'},5000); } As a result, we have: - the cursor is not pointer, - it does not click, - there is no animation on hover.
The problem appeared after sewing on jQuery. help ...
ps: What should look like, or rather be written, similar code that performs the functions that this should perform? Thank!