click function load on a page and not in another page.
Hello all.
I'm quite a new jQuery user.
I've got a strange problem.
In an Ajax page I've made a jQuery script that works fine. It switch src between IMG tags:.
My script:
- $("#img_thumb1").click(function(){
- var src_img_thumb1 = $("#img_thumb1").attr('src');
- var src_img_main = $("#img_main").attr('src');
- $("#img_main").attr("src", src_img_thumb1);
- $("#img_thumb1").attr("src", src_img_main);
- });
The HTML:
- <a href="#">
- <img id="img_main" src="flower.jpg">
- </a>
- <a href="#">
- <img id="img_thumb1" src="tree.jpg">
- </a>
I've add the "a" tag for having the hand on the mouse pointer. There's certainly a more elegant way to do it.
So here is the problem, when I replicate the same code in a non Ajax page, it don't works.
jQuery works as this works:
- $(document).ready( function () {
- alert("Ok document ready")
- });
Someone have a solution, or can give me a way to debug the code?
Thanks.