Create a function to a function that runs a for loop?
Posted
by
user637364
on Stack Overflow
See other posts from Stack Overflow
or by user637364
Published on 2011-03-07T08:09:10Z
Indexed on
2011/03/07
8:10 UTC
Read the original article
Hit count: 189
jQuery
Hi,
I have made some code that creates a red border around an image when the user click on to highlite thats the choesen one. But I want to erase previous or all border with a white border around all images before a new click is made on another image. My question is how do I activate a call to a function when a click is made and how would a function look in jQuery? I just whant to use the .css to change the border in perhaps a loop and change the id of the images? Can I mix common javascript with jQuery, or should it only be pure jQuery code in a script?
This is a simplified part of the code, it contains "minibild_1" to "minibild_5"
$(document).ready(function(){
$("#minibild_1").click(function(){
$("#minibild_1").css({"border":"2px solid #D00C33"});
$("#storbild").attr("src","../bilder/bilder_stora/{$row1->bild_1}.jpg");
});
$("#minibild_2").click(function(){
$("#minibild_2").css({"border":"2px solid #D00C33"});
$("#storbild").attr("src","../bilder/bilder_stora/{$row1->bild_2}.jpg");
});
});
© Stack Overflow or respective owner