1

空的專欄中,我想在editform.aspxSharePoint內容查詢網頁組件:隱藏與jQuery

</script> 
<script language="JavaScript"> 
$(document).ready(function() 
{ $('nobr:contains("columnname")').closest('tr').hide() }); 
</script> 

它可以隱藏列表列。 但現在我想隱藏它,如果沒有價值。這個怎麼做?

+0

你應該能夠在input元素上使用jQuery VAL()然後隱藏獲取內容如果val()== 「」 – Luis

回答

1
$(document).ready(function() 
{ if ($('nobr:contains("columnname")').val() == "") 
    { 
    $('nobr:contains("columnname")').closest('tr').hide() 
    } 
}); 
0
<script language="JavaScript"> 
$(document).ready(
    function() 
    { 
    // Creating an object to reduce JQuery selector to get the same element again 
    // which reduces a considerable lines of code being interpreted from JQuery lib 
    // which is expensive operation than having a reference object in hand. 
    var myElement = $('nobr:contains("columnname")'); 

    // since they typeof(myElement.val().length) is number, 
    // you can use === conditional operator. 
    // '===' is faster. The reason being, that it only needs to compare the type, 
    // and if that matches, compare the raw data. 
    // The == operator will try to convert one type to another if they don't match. 
    // This will be a more expensive operation in most cases. 
    if(myElement.val().length === 0) //or if(myElement.val() === "") 
    { 
    myElement.closest('tr').hide(); 
    } 
    } 
); 
</script>