开发者

jQuery live right click

开发者 https://www.devze.com 2023-01-03 21:24 出处:网络
How can i use the jQuery live function as a right click listener? I\'ve used this plugin: http://abeautifulsite.net/2008/05/jquery-right-click-plugin for right click event listening. But it isn\'t li

How can i use the jQuery live function as a right click listener?

I've used this plugin: http://abeautifulsite.net/2008/05/jquery-right-click-plugin for right click event listening. But it isn't live, which is a pr开发者_开发问答oblem for me.

Hope you can help

(btw. sorry for my bad english)

Thanks in advance


rightClick() is just a function that assigns regular mouse events. The function disables the context menu.

You may be better off just calling rightClick() on your images directly in the code that dynamically creates them.

var $myNewImage = $('<img src="some/path.jpg" />');
    $myNewImage.rightClick(function(){
                               // Your right click code
                           });

$myNewImage.appendTo(selector);


I haven't gone thru the plugin code but try this out.

$("#selector").live("rightClick", function(e) {
     // Do something
});


Try:

var $myNewImage = $('<img src="some/path.jpg" />');
$myNewImage.bind("rightClick",function(){
                           // Your right click code
                       });

$myNewImage.appendTo(selector);

Or if you like chaining:

 var $myNewImage = $('<img src="some/path.jpg" />')
     .bind("rightClick",function(){
     // Your right click code
     })
    .appendTo(selector);
0

精彩评论

暂无评论...
验证码 换一张
取 消