I need some JQuery code so that I can add a CSS border to an image when I click on it.
<img src="myimage" onclick="AddBorder();" />
If you're using jQuery, I'd recommend removing the inline onclick handler, as that's the less desirable way to bind to the event:
<img src="http://jsfiddle.net/img/logo.png" />
And then just setup a simple event binder:
$(function () {
$("img").click(function() {
$(this).css('border', "solid 2px red");
});
});
Here's a jsfiddle
Er... what have you tried so far?
function AddBorder() { $(this).css('border','1px solid red'); }