0

How can I accomplish something like this:

function (e) { 
if(e.("#this_button_is_clicked").true)
{//then do this}
});

?

EDIT:

 $("body").click
       (
         function (e) {
             if (e.target.className !== cls || e.target.click("#bUpdate")) {
               //do this
             }
         }
       );

I have a text box, and whenever I click somewhere else it fires on blur to that text box.But when I click to button looks like it doesn't see it as a 'body.click' so I just wanted to add it in my condition as button.clicked.true

Shoe
  • 74,840
  • 36
  • 166
  • 272
InGeek
  • 2,532
  • 2
  • 26
  • 36
  • 2
    Could you please explain in words what you are trying to do? This pseudo code does not make a lot of sense to me. Where does `e` come from? – Felix Kling Jan 28 '13 at 19:34
  • Getting id of the element clicked might give some clue - http://stackoverflow.com/questions/48239/getting-the-id-of-the-element-that-fired-an-event-using-jquery – Ravindra Gullapalli Jan 28 '13 at 19:36
  • He's already gotten the id it is `#this_button_is_clicked` – Ryan Jan 28 '13 at 19:36
  • I've edited the question, cls is the name of my div where I manage my text box. – InGeek Jan 28 '13 at 19:45

1 Answers1

1

jQuery event objects have a target property:

if ($(e.target).is("#this_button_is_clicked"))
{
    console.log(e);
}
Matt Zeunert
  • 16,075
  • 6
  • 52
  • 78
  • thank you,i tried this one, didn't work. I tried this: e.target.is("#bUpdate") – InGeek Jan 28 '13 at 19:47
  • @INgeeg That's because `.is()` is a jquery method, and you need to wrap `e.target` in the jquery object in order to access it's methods. – Daedalus Jan 28 '13 at 19:53