Choose ID With Contextmenu
Choose ID With Contextmenu
我想用contextmenu编辑控件。当我点击右键,我需要得到菜单id号,但它只写第一个菜单id。我怎样才能修好它?
$('#kutu').bind('contextmenu',function(e){
var $cmenu = $(this).next();
var ix = $(this).parent().find("h1").parent().find("div").html();
$("#bilgiler").html(ix);
$('<div class="overlay"></div>').css({left : '0px', top : '0px',position: 'absolute', width: '100%', height: '100%', zIndex: '100' }).click(function() {
$(this).remove();
$cmenu.hide();
}).bind('contextmenu' , function(){return false;}).appendTo(document.body);
$(this).next().css({ left: e.pageX, top: e.pageY-15, zIndex: '101' }).show();
return false;
});
和我的PHP菜单代码…
echo '<H1 class="ustBaslik" id="fakulteBilgileriH1">';
echo '<img src="../resimler/bolge.png" alt="" /> '.$cek["KategoriIsmi"].$cek["KategoriID"];
echo '<div style="display:none">'.$cek["KategoriID"].'</div></H1>';
为测试:http://jsfiddle.net/6KdKC/3/
修改脚本为:
$('#kutu h1').bind('contextmenu', function(e) {
var $cmenu = $(this).parent().next();
var ix = $(this).find('div').html();
$("#bilgiler").html(ix);
$('<div class="overlay"></div>').css({
left : '0px'
, top : '0px'
, position: 'absolute'
, width: '100%'
, height: '100%'
, zIndex: '100'
}).click(function() {
$(this).remove();
$cmenu.hide();
}).bind('contextmenu', function(){
return false;
}).appendTo(document.body);
$cmenu.css({
left: e.pageX
, top: e.pageY - 15
, zIndex: '101'
}).show();
return false;
});
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- WebComponentsJS with IE10
- 指令的模板必须只有一个根元素:With restrict E&替换true
- timeago.js with datatable and PHP
- Ajax and Json with Rails
- errors with Javascript try catch
- how to split a string with ','
- Understanding Javascript scope with "var that = this&qu
- Architecture for CPU intensive tasks with NodeJS & Socke
- How to declare a Map containing certain properties with flow
- 设置'这'在React with Inverse Data Flow中
- Unit-testing multiple use cases with Karma & Mocha.js
- Modify Javascript with C#
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- Using jQuery with classes from ES6
- Choose ID With Contextmenu