Javascript examples for jQuery:Mouse Event
Create Div and set style and add click event handler
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <script> $('body').html('<div id = "box">123</div>'); $('#box').css('color','green'); $('#box').css('font-weight','500'); $('#box').click(function(){ console.log('You clicked here'); });/*w ww . j a v a2s . c om*/ </script> </body> </html>