简体   繁体   English

如何使用Javascript查找特定的隐藏HTML标记

[英]How to find a specific hidden HTML tag with Javascript

How to find and override a specific hidden HTML tag (this will appear with mouseover) as <a> tag with both title="Add" and evtid="new_item" and replace (not using setAttribute) the href element to href="something goes here" with Javascript and jQuery. 如何使用title="Add"evtid="new_item" <a>标签查找覆盖特定的隐藏 HTML标签(将随鼠标悬停一起显示),并将href元素替换(不使用setAttribute)到href="something goes here"使用JavaScript和jQuery。

HTML: 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>

My code goes here: 我的代码在这里:

 _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");

});

Try, 尝试,

$("#AsynchronousViewDefault_CalendarView")
    .find('a[title="Add"][evtid="new_item"]')
      .attr('href',"http://share/Lists/Calendar.aspx?P=P1");

DEMO 演示

$(document).ready(function () {
   $("a[href='javascript:void(0)']").attr('href', 'http://share/Lists/Calendar.aspx?P=P1');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM