[英]Trouble selecting an element for overriding
In a SharePoint list page I'm trying to override what happens on the 'Edit Item' icon and go to my own URL. 在SharePoint列表页面中,我试图覆盖“编辑项”图标上发生的情况,然后转到我自己的URL。
The full element looks like this: 完整元素如下所示:
<a unselectable="on" href="javascript:;" onclick="return false;" class="ms-cui-ctl-large " aria-describedby="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/inc/1033/ipfsimages.png" style="top: -32px; left: -32px;"></span></span><span unselectable="on" class="ms-cui-ctl-largelabel">Edit<br>Item</span></a>
I've matched other elements on the same page without issue. 我已经在同一页上匹配了其他元素,没有任何问题。 This particular one is being difficult.
这个特殊的人很难。
I have tried both of these ways but not getting it: 我尝试了这两种方法,但没有得到:
$('a[id="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit-Large"]').removeAttr("onclick").click(function() {
location.href = "https://mycustomurl";
});
$('a[id="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit-Large"]').attr('href','https://mycustomurl');
Thank you for the help! 感谢您的帮助!
You need to remove the onclick
attribute, I notice that is returning false, so not bubbling, or following the href. 您需要删除
onclick
属性,我注意到这返回的是false,所以不要冒泡或遵循href。
.attr("onclick", "")
$('a[id="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit-Large"]').attr('href', 'www.google.ca').attr("onclick", "");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a unselectable="on" href="javascript:;" onclick="return false;" class="ms-cui-ctl-large " aria-describedby="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.ContextualTabs.InfoPathListDisplayTab.Manage.Controls.btnEdit-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/inc/1033/ipfsimages.png" style="top: -32px; left: -32px;"></span></span> <span unselectable="on" class="ms-cui-ctl-largelabel">Edit<br>Item</span> </a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.