Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery隐藏一个元素,但它';它不工作了_Jquery_Html_Sharepoint - Fatal编程技术网

jQuery隐藏一个元素,但它';它不工作了

jQuery隐藏一个元素,但它';它不工作了,jquery,html,sharepoint,Jquery,Html,Sharepoint,我在SharePoint(aspx)中有一个页面。我试图使用jQuery隐藏td控件。我已经从开发者工具和jquery附加了呈现的html。杰弗里德尔来了 html代码 <table class="ms-WPBody" style="padding-top: 0px; width: 100%;"> <tbody><tr> <td valign="top" style=

我在SharePoint(aspx)中有一个页面。我试图使用jQuery隐藏td控件。我已经从开发者工具和jquery附加了呈现的html。杰弗里德尔来了

html代码

<table class="ms-WPBody" style="padding-top: 0px; width: 100%;">
                    <tbody><tr>
                        <td valign="top" style="padding-left:4px;padding-right:4px;"></td><td id="ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage" width="100%" style="padding-left:4px;padding-right:4px;">The default value specified is not valid.</td>
                    </tr>
                </tbody>
 </table>

指定的默认值无效。
jquery代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> </script>

<script type="text/javascript">
    $(function() {

        var filterErrorText = "ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage";
        var filterErrorTextID = document.getElementById(ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage).innerText;
        alert(document.getElementById("ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage").innerText);
        alert(filterErrorTextID);
    /*  if(filterErrorTextID)
        {
            alert(filterErrorTextID);
            //filterErrorTextID.style.display="none";
        } */
    }); 
</script>

$(函数(){
var filterrortext=“ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage”;
var filterrortextid=document.getElementById(ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage);
警报(document.getElementById(“ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage”).innerText);
警报(FilterErrorExtId);
/*如果(FilterErrorExtId)
{
警报(FilterErrorExtId);
//filterrortextid.style.display=“无”;
} */
}); 

您的脚本没有使用jquery。 您应该使用jQuery hide()函数,如

$('#ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage').hide();

我没有看到你试图隐藏
td
元素。这里有两个,但不清楚到底是哪一个。如果你真的想隐藏它,你应该先用谷歌搜索解决方案,我相信你应该自己解决这个问题。不要把DOM调用和jQuery混合在一起。用一个或另一个。您可能想要
$(“#”+filterErrorText).hide()
只是一个建议:不要在sharepoint中使用类似“ctl00_m_g_1c59424a_162b_4285_8f9a_33109bdfc04f_DefaultValueMessage”的ID以元素为目标。始终使用div[id$=“\u DefaultValueMessage”]。jQuery hide函数工作正常。但是,我必须评估该控件是否包含文本。这就是为什么我尝试使用innerHtml或innerText发出警报,但没有一个可以使用jQuery,因为有.text()函数可以返回内部文本。