Jump to content

Javascript that detects class


codingmasterRS

Recommended Posts

Hi guys,

I have this img class

 

<img src="avatars/21.png" class="online" onMouseDown="if(event.button==2){alert('Initiate IM session');}" />

 

now what I need is to change toe onMouseDown event so that it has an additional IF, the additional IF needs to check if class="online" or their is no class.

 

Cheers in advance, tried googling couldn't find what I was after.

 

All help much appreciated,

Link to comment
https://forums.phpfreaks.com/topic/239038-javascript-that-detects-class/
Share on other sites

There is no .rightClick. Are you guessing?

 

If you need right-click too (why? that's not typical) then use .mousedown() and event.which for the button.

.mousedown(function(e) {
    if (e.which == 1 || e.which == 3) {
        // ...
    }
});

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.