dplumbonline
dplumbonline

Reputation: 51

Fire click event once per (different) class

I'm trying to have a click event fire on any tag with the same class only once.

I tried using '.one', although, it removes itself after the first class tag is clicked.

$(document).ready(function() {   
    $(".dropdown").one('click', function() { 
        ...
    });
});

The code is bought in from another .php file on the same directory with some server information so there are multiple (no end) in the number of tags with the same class.

<div class = \"dropdown\" id=" . $row["name"] . "dropdown" . ">
                    <div>". $row["email"] . "</div>
                    <div>name:" . $row["name"] ."</div>
                    <div>". $row["email"] ."</div></div>
                    ";

Any recommendations?

Upvotes: 3

Views: 128

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

As per your comments what you actually needs to do is apply a check of text available already or not?

$(document).ready(function() {   
    $(".dropdown").on('click', function() { 
       if(empty($('<text wrapper class or id>').text())){
           // add code to bring the info
       }
       //rest other code.
    });
});

Note : I fyou can show your code HTML then I can Update my code to give you concreete answer. The above will guide you how to proceed.

Upvotes: 1

Related Questions