Create a function to a function that runs a for loop?
- by user637364
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");
});
});