Basic stuff for those who know what they're doing with js - useful to me, when intranets keep stripping URLs and things! <script type="text/javascript"><!-- window.onload = function() { if (window.jQuery) { // jQuery is loaded alert("jQuery loaded -Yeah!"); } else { // jQuery is not loaded alert("jQuery Doesn't Work"); } if (jQuery.ui) { // UI... Continue Reading →
Use jQuery to make an array of div items
var boxes = $('.box'); $(boxes[0]).click(function() { alert('hi'); }
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/