onclick怎么接收js传过来的变量

WBOY
Release: 2016-06-13 12:54:55
Original
926 people have browsed it

onclick如何接收js传过来的变量?
html:


JS:
<script><br /> $(function(){<br /> var glob_oplist = new Array();<br /> $("#select2").each(function(){<br /> $(this).children("option").each(function(){<br /> <br /> glob_oplist.push($(this).val());<br /> });<br /> <br /> });<br /> dtitles=JSON.stringify(glob_oplist);<br /> });<br /> </script>
我想把JS最后得到dtitles的值作为参数赋给action以GET方式传递给DO.php页面,请问这个JS的值如何在ONCLICK事件里写?


------解决方案--------------------
dtitles=JSON.stringify(glob_oplist);
window.location.href='do.php?action='+dtitles;
------解决方案--------------------
$(function(){
$("#btn_test").attr("onClick","alert(1)");
});
LZ可以按上面方法,在页面加载完成时,改写那个按钮的onClick属性值
把你的参数加进去
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template