Php jQuery更改链接href with.load()

Php jQuery更改链接href with.load(),php,jquery,html,ajax,Php,Jquery,Html,Ajax,我正在尝试制作一个类似dropbox的自定义上下文菜单。我需要的是,当用户右键单击某个元素时,上下文菜单中弹出的“编辑”和“删除”等选项将链接到该特定元素的“编辑”和“删除”。关联菜单: <div class="screenlock-transparent"> <div class="context-menu-wrapper"> <ul class="context-menu"> <a href="<?php echo $e

我正在尝试制作一个类似dropbox的自定义上下文菜单。我需要的是,当用户右键单击某个元素时,上下文菜单中弹出的“编辑”和“删除”等选项将链接到该特定元素的“编辑”和“删除”。关联菜单:

<div class="screenlock-transparent">
<div class="context-menu-wrapper">
    <ul class="context-menu">
        <a href="<?php echo $edit_url; ?>"><li><i class="icon-edit" style="margin-right: 10px;"></i>Edit</li></a>
        <a href="<?php echo $delete_url; ?>"><li><i class="icon-trash" style="margin-right: 10px;"></i>Delete</li></a>
    </ul>
</div>
</div>

我的做法是,当用户右键单击某个元素时,使用jQuery触发一个事件:

<script type="text/javascript">
$(document).ready(function(){
    // Launch on-right-click on element
    $(".custom-context-menu").mousedown(function(){
        if(event.which == 3) {
            if ($(this).hasClass("ul-all-years-faculty")) { // If on the general faculty ul
                // Load external php here to build url string specific to the element
                // Replace current href value with the url string produced by the external php script
            } else if ($(this).hasClass("ul-year-specific-faculty")) {
            } else if ($(this).hasClass("ul-semester")) {
            } else if ($(this).hasClass("ul-subject")) {
            }
        }
    });
});
</script>

$(文档).ready(函数(){
//在元素上单击鼠标右键启动
$(“.custom上下文菜单”).mousedown(函数(){
if(event.which==3){
if($(this).hasClass(“ul所有年份教员”){//if在普通教员ul上
//在此处加载外部php以构建特定于元素的url字符串
//用外部php脚本生成的url字符串替换当前href值
}else if($(本).hasClass(“ul年度特定教员”)){
}else if($(本).hasClass(“ul学期”)){
}else if($(this).hasClass(“ul主题”)){
}
}
});
});
如果if语句是我试图编写调用外部php脚本并将上下文菜单中的“Edit”链接的href替换为包含右键单击元素特定变量的url的href的代码的地方,您将看到引号

我知道如何对div使用.load()-$(“#ID”)。load(…)将加载到该div内的回显内容中。但是,在链接(a)的href内加载如何


非常感谢你。非常感谢您的帮助。

如果我理解正确,并且您希望更改a标记的href,那么您需要使用.attr()函数

看起来是这样的

$("a").attr("href", "http://newlink.com")

如果我理解正确,并且您希望更改a标记的href,那么您需要使用.attr()函数

看起来是这样的

$("a").attr("href", "http://newlink.com")