SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast whitecreek's Avatar
    Join Date
    Aug 2011
    Location
    Madrid, Spain
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Allowing click on one only element

    Hi there, another simple (I hope) task.

    The thing is to allow clicking only once and only on one of the rectangles. That is, after clicking on one (any of the) rectangle, no more of them should be available for clicking. I guess it could be done somehow substituting <article> tags for <input> fields, in the example, and disabling all rest <input> fields after clicking on one of them. Here is the example:

    http://www.sportmediamanager.com/test-rasca-gana/

    Is there a simple way to get that provided the markup as it is right now?


    Thanks very much in advance guys,

    Whitecreek.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,312
    Mentioned
    177 Post(s)
    Tagged
    8 Thread(s)
    Hi whitecreek,

    Just unbind the click event:

    Code JavaScript:
    $(".caja-padre > div > article").on("click", function(){
      $(this).fadeOut(100);
      $(".caja-padre > div > article").off("click");
    });

  3. #3
    SitePoint Enthusiast whitecreek's Avatar
    Join Date
    Aug 2011
    Location
    Madrid, Spain
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pullo,

    Thanks for the quick answer. I tried, after a short research:

    Code JavaScript:
    $(".caja-padre > div > article").bind("click", function(event){
      			$(this).fadeOut(100);
      			$(".caja-padre > div > article").unbind(event);
    		        });

    without success, which got me a bit disoriented. Now I realise I wasn't specifing 'click' at all in the second argument of the function..... My wrong.

    Anyway, your solution is working just fine. Neat and simple. Thanks again mate.

    Best regards,

    Whitecreek.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,312
    Mentioned
    177 Post(s)
    Tagged
    8 Thread(s)
    Glad you got it working.
    Thanks for taking the time to report back

  5. #5
    SitePoint Enthusiast whitecreek's Avatar
    Join Date
    Aug 2011
    Location
    Madrid, Spain
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wasn't quite as busy this time, hehe
    Cheers!!


Bookmarks

Posting Permissions

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