This is simple.
In javascript:
To keep your HTML clean (without any event attributes inside tags) you should give something an event using javascript, that way if you have to modify the JavaScript anytime it is easy and vise versa for HTML tags. An example for this using Anchor tags would be (in jQuery):Code:function openPopup(url) { window.open(url); return false; }
Which would be used with this HTML:Code:$(document).ready(function() { $("#anchors a").click(openPopup); }); function openPopup() { window.open(this.src); return false; }
HTML Code:<div id="anchors"> <a href="page2.html">Page 2</a> </div>


Reply With Quote


