I am using MVC 5 and html table to render a view. In one of the table cell, I want to check if the value inside the td tag is null or not and show or hide an item using JQuery. I am using the code below but for some reasons the value inside the tag is showing "\n \n" and therefore always not null. I have included a screen and my code. Any help to remove "\n \n" so I can check if the value is null or not will be appreciated.
- $(document).ready(function(){
- $("button").click(function()
- {
- var v = $("#hideheader").html(); ----> This value here is showing "\n \n"
- if(v=='') --- This is always not empty
- {
- alert('empty');
- $("#hide").hide();
- }
- else
- {
- alert('non-empty value');
- }
- });
- });
- <table>
- <thead><tr> <th id="hide">ID</th></tr> </thead>
- <tbody><tr><td id="hideheader">@item.adminstring</td></tr></tbody>
- </table>