attasz
03-27-2010, 01:15 PM
I wrote a script what didn't work fine,so i deleted everything except the basics:
$(document).ready(function(){
var num = 8;
var text = "";
var r = 1;
for(var a = 1;a <=2;a++)
{
for(var i = 1;i <=num;i++)
{
text += "<div class = 'keret'><img src = 'docs/" + i + ".png' class = 'kep' alt = '" + r + "'></div>";
r++;
}
}
$("#pic_box").html(text);
$(".kep").click(function(){ //first function
$(this).removeClass().addClass("selected");
});
$(".selected").click(function(){ //second function
alert("sys");
});
});
Shortly,i fill up the pic_box with pictures,if i click on a picture i give it the class: "selected".
But if i click on a picture with the class "selected",nothing happens.
If i take the 2. function inside the 1. function,it works,the alert pops up.
I don't understand why the second func can't work outside the first,is there some inheritance,or what?:confused:
$(document).ready(function(){
var num = 8;
var text = "";
var r = 1;
for(var a = 1;a <=2;a++)
{
for(var i = 1;i <=num;i++)
{
text += "<div class = 'keret'><img src = 'docs/" + i + ".png' class = 'kep' alt = '" + r + "'></div>";
r++;
}
}
$("#pic_box").html(text);
$(".kep").click(function(){ //first function
$(this).removeClass().addClass("selected");
});
$(".selected").click(function(){ //second function
alert("sys");
});
});
Shortly,i fill up the pic_box with pictures,if i click on a picture i give it the class: "selected".
But if i click on a picture with the class "selected",nothing happens.
If i take the 2. function inside the 1. function,it works,the alert pops up.
I don't understand why the second func can't work outside the first,is there some inheritance,or what?:confused: