如何查找并覆盖特定的隐藏 HTML标记(这将以鼠标悬停方式显示)为<a>
标记title="Add"
和evtid="new_item"
并使用Javascript和jQuery将href
元素替换(不使用setAttribute)到href="something goes here"
。
HTML:
<div id="AsynchronousViewDefault_CalendarView">
<div class="ms-acal-header">
<div>
<table class="ms-acal-month">
</table>
<div class="ms-acal-vlink">
<table>
<tbody>
<tr>
<td><a href="javascript:void(0)" title="Add" evtid="new_item">
<img border="0" src="/_layouts/images/caladd.gif">Add</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
我的代码在这里:
_spBodyOnLoadFunctionNames.push("OpenDialog1");
$(document).ready(function OpenDialog1() {
var nnnn = $("#AsynchronousViewDefault_CalendarView");
var element = nnnn.querySelector('[title="Add"]');
element.replace("javascript:void(0)", "http://share/Lists/Calendar.aspx?P=P1");
});
答案 0 :(得分:2)
尝试,
$("#AsynchronousViewDefault_CalendarView")
.find('a[title="Add"][evtid="new_item"]')
.attr('href',"http://share/Lists/Calendar.aspx?P=P1");
答案 1 :(得分:1)
$(document).ready(function () {
$("a[href='javascript:void(0)']").attr('href', 'http://share/Lists/Calendar.aspx?P=P1');
});