2013-12-17 3 views
0

Просьба сообщить, как добиться этого, скрыть таблицу html innter при загрузке страницы и нажать кнопку поиска, таблица будет отображаться только с результатами. Я не хочу показывать пустой table.Please см. ниже код, который я пробовал.Отобразите таблицу при нажатии кнопки - JQuery/javascript

Но обязательно, после того, как кнопка на кнопке обновится.

$(document).ready(function() {  

    $("#historylist").hide(); 

    $("#historysearch").click(function() { 
     $("#historylist").show(); 
    }); 
    // } 
});  

<table id="searchTbl" width="800" > 
<tr> 
    <td valign="top">Release No</td> 
    <td valign="top"> 
     <input type="text" name="releaseNo" value="" style="width:200" /> 
    </td> 
    <td valign="top"><input type="button" value="Search" onClick="commit()" style="width:80" id="historysearch"/></td> 
</tr> 
<br /><br /> 

    <table border="1" cellpadding="2" cellspacing="0" id="historylist"> 
    <tr> 
     <th><font size="-1">Header1</font></th> 
     <th><font size="-1">Header2</font></th> 
     <th><font size="-1">Header3</font></th> 
     <th><font size="-1">Header4</font></th> 
     <th><font size="-1">Header5</font></th> 
    </tr> 
    </table> 
</table> 

JavaScript:

function commit(){ 

    document.menu.cmd.value='search'; 
    document.menu.submit();  
} 

Когда нажмите на кнопку она показывает таблицу и снова пряча таблицу.

$(document).ready(function() { 
$("#historylist").hide(); 
$("#historysearch").click(function(e) { 
    e.preventDefault(); 
    $("#historylist").show(); 
    commit(); // moved from the onClick attribute }); 
}); 

ответ

0
$("#historysearch").click(function(e) { 
    e.preventDefault(); 
    $("#historylist").show(); 
    commit(); // moved from the onClick attribute 
}); 

http://api.jquery.com/event.preventDefault/

+0

Когда нажмите на кнопку она показывает таблицу и снова пряча таблицу. $ (document) .ready (function() { $ ("# historylist"). Hide(); $ ("# historysearch"). Click (function (e) { e.preventDefault(); $ («#historylist»). show(); commit(); // перешел из атрибута onClick }); }); – user2848031

Смежные вопросы