Adding data to divs with jQuery

I am only beginning to experiment with JS with more depth, and have discovered jQuery has a data function which lets you store data against individual divs. Really useful for some bits and peices! $("#box0").data("uniqueID", 0); $("#box1").data("uniqueID", 1); Then to call it, $("#box0").click(function() { alert($(this).data("uniqueID")); I'll find out how to loop that through a set... Continue Reading →

Make a whole DIV a link the easy way with Jquery

<script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script> <script type="text/javascript"> function init() { $(".simBox").click(function(){ window.location=$(this).find("a").attr("href"); window.open($(this).find("a").attr("href")); return false; }); $(".simBox").mouseover(function(){ $(this).addClass("simBoxOver"); }); $(".simBox").mouseout(function() { $(this).removeClass().addClass("simBox"); }); } $(document).ready(function() { init(); }); </script> </head> <body> How do I...<br><br> <div class="simBox"><a href="about:blank">Enrol in elearning?</a></div> Src: http://css-tricks.com/snippets/jquery/make-entire-div-clickable/

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑