【发布时间】:2015-04-03 12:22:23
【问题描述】:
我通过 url 发送一个特定的值,然后我的页面得到刷新。 URL 值是动态的。每当设置 URL 时,我都想显示已经隐藏的 div。
<button id="show_id" onclick="location.href='opdcasepaperreport.php?patient_nm='+document.getElementById('patient_id').value;" > View Report </button>
当用户点击 View Report 时,将显示报告 div。 我尝试了以下两种编码方法:
$( document ).ready(function()
{
$("#show_id").click(function()
{
$('#main').toggle();
});
});
和
$(document).ready(function ()
{
if(window.location.href.indexOf("?patient_nm"))
{
//alert("your url contains ");
//show code;
}
});
在第一种情况下,由于页面刷新 div 再次可见和不可见。 有没有像 php 中这样的解决方案 if(isset(---)){//do this;}
【问题讨论】:
-
你想在主页或点击后的重定向页面上隐藏/显示div吗?
-
您正在使用按钮做两件事。使用 jquery 函数使 div 隐藏/显示,并且您还应用了 onclick 将页面重定向到特定 url。是故意的吗?如果您保留此实现,则页面将由于稍后的功能(onclick)而刷新/重定向
标签: javascript php jquery html