Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    problem with jquery

    Hi guys ... i have a problem... i created a object this way:
    $("#link").click(function () {
    $("#form").html(" <a href='#' id='f****'> dfs f sd f </a> ");

    return false;
    });

    thats all right, its works fine... but when i want make a action on this objekt like this:


    $("#f****").click(function(){
    var exitt = confirm("Naozaj chcete opustiť chat?");
    if(exitt==true){window.location = 'index.php?logout=true';}

    });

    it doesnt work but when i just create it on standart way in html code <a href="#" id="f****"> click </a>

    $("#f****").click(function(){
    var exitt = confirm("Naozaj chcete opustiť chat?");
    if(exitt==true){window.location = 'index.php?logout=true';}

    });

    it works... why i cant make a action on object which i created with .html method ? :P thx a lot if u know the answer
    Last edited by Trki; 01-08-2012 at 11:20 PM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    You can ... if you either

    1. execute the .click() AFTER you inserted the html() OR
    2. use the .live('click', ...) instead of .click() or .on() for jQuery 1.7.x

  • Users who have thanked devnull69 for this post:

    Trki (01-08-2012)

  • #3
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts
    thx a lot i did try your first alternative and it works well. I connected this two scripts into one and ... it works thx


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •