<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script src="javascript/jquery-1.3.1.js" type="text/javascript"></script>
<link href="facefiles/facebox.css" rel="stylesheet" type="text/css" />
<script src="facefiles/facebox.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
$(document).ready(function() {
$("#alert").facebox();
/
})
function alertinfo()
{
var a=document.getElementById("Text1").value;
alert(a);
}
</script>
<a href="#mydiv" id="alert">View DIV with id="mydiv" on the page</a>
<div id="mydiv" style="display:none"> <input id="Button1" type="button" value="button" onclick="alertinfo()"/><input id="Text1" type="text" />
This is the contents of a hidden DIV on the page, with ID="mydiv" and style set to "display:none"<br /><br />
<a href="http://www.dynamicdrive.com/dynamicindex4/facebox/index.htm">Facebox image and content viewer (v 1.1)</a>
</div>
</form>
</body>
</html>
怎么获取不到要弹出DIV里面表单的值啊,谁能帮帮我啊,这个插件是不是有问题
<head runat="server">
<title>无标题页</title>
<script src="javascript/jquery-1.3.1.js" type="text/javascript"></script>
<link href="facefiles/facebox.css" rel="stylesheet" type="text/css" />
<script src="facefiles/facebox.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
$(document).ready(function() {
$("#alert").facebox();
/
})
function alertinfo()
{
var a=document.getElementById("Text1").value;
alert(a);
}
</script>
<a href="#mydiv" id="alert">View DIV with id="mydiv" on the page</a>
<div id="mydiv" style="display:none"> <input id="Button1" type="button" value="button" onclick="alertinfo()"/><input id="Text1" type="text" />
This is the contents of a hidden DIV on the page, with ID="mydiv" and style set to "display:none"<br /><br />
<a href="http://www.dynamicdrive.com/dynamicindex4/facebox/index.htm">Facebox image and content viewer (v 1.1)</a>
</div>
</form>
</body>
</html>
怎么获取不到要弹出DIV里面表单的值啊,谁能帮帮我啊,这个插件是不是有问题
$("#alert").click(function(){
alert($("mydiv").text);
});
})
首先要facebox 的弹出层是相当于复制了一个层,然后显示出来,所以你用那个方法获取到的是原来层里面的表单值。
解决的方法是:在原来层里面加入触发事件,当输入完毕离开表单之后,就执行一段JS代码插入到那个层里的一个隐藏变量,暂时存储起来,然后点击提交的时候 调取JS 代码,将你刚才赋值的表单值获取出来就可以了,不知道还有更好的办法没,暂时没去研究,欢迎光临我的网站分鲜网里面有实例,下面贴出我写的代码:
<div id="want" style="display:none; width:300px;">
<div style=" font-family:'黑体',Verdana, Arial, Helvetica, sans-seri; font-weight:bold; font-size:14px;">我要去 {$shop.shop_name}</div>
<textarea name="want_content" id="want_content" cols="40" rows="5" style="border:1px solid#005eac; padding:5px; color:#999999;" onclick="this.value='';" onblur="insert_html(this);">你想去做什么?</textarea>
<div style="width:300px;">
<div style="width:300px; padding:5px 0px;">
<input type="checkbox" name="tongbu" id="tongbu" checked="checked" /> <span style="color:#666666;">同步到我的社交网络</span>
</div>
<input type="button" class="blue60_25_btn" id="do_want" onclick="do_want();" value="发布" />
<input type="hidden" name="content" value="" />
<script language="javascript" type="text/javascript">
function insert_html(obj)
{
var content = (obj.value);
$("input[name='content']").attr("value",content);
}
function do_want()
{
var want_content = $("input[name='content']").val();
alert(want_content);
}
</script>
<input type="button" class="blue60_25_btn" onclick="close_face()" value="取消" />
</div>
</div>