Php 使用out元素或事件在jQuery中调用函数
我想调用函数my(),它显示在Php 使用out元素或事件在jQuery中调用函数,php,jquery,Php,Jquery,我想调用函数my(),它显示在 jQuery(function ($) { var showing = { apper: function my () { $("#element").click(function (e) {//>>>>>>>>>>>>This function, which I want to call it. e.preventDefault();
jQuery(function ($) {
var showing = {
apper: function my () {
$("#element").click(function (e) {//>>>>>>>>>>>>This function, which I want to call it.
e.preventDefault();
var f = document.forms["ff"]["p_1"].value;
if(f=="1234")
$("#content").modal({
overlayId: 'overlay',
containerId: 'container',
closeHTML: null,
minHeight: 80,
opacity: 65,
position: ['0',],
overlayClose: true,
onOpen: showing.open,
onClose: showing.close
});
});
},
open: function (d) {
var self = this;
self.container = d.container[0];
d.overlay.fadeIn('slow', function () {
$("#content", self.container).show();
var title = $("#title", self.container);
title.show();
d.container.slideDown('slow', function () {
setTimeout(function () {
var h = $("#data", self.container).height()
+ title.height()
+ 20; // padding
d.container.animate(
{height: h},
200,
function () {
$("div.close", self.container).show();
$("#data", self.container).show();
}
);
}, 300);
});
})
},
close: function (d) {
var self = this;
d.container.animate(
{top:"-" + (d.container.height() + 20)},
500,
function () {
self.close();
}
);
}
};
showing.apper();
});
就像下面代码中的onclick=“my();”
一样
<form id="ff" name="l" method="POST" action="dd.html" >
<input id="p_1" name="p_1"/>
<input id="p_2" name="p_2"/>
<input type="submit" id="" onclick="my();" /> //<<<<<<< I want to call here.
</form>
// 您不需要绑定onclick,也不需要调用onclick来执行某些操作。
就这么做吧
函数callOperation(){
警报($(“#p#u 1”).val());
}
您想用showing
变量做什么?元素在哪里?showing.apper()代码>我想在对话框窗体中显示div内容,而不是alert
<head>
<meta charset="utf-8" />
<title></title>
<script data-require="jquery" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function callOperation(){
alert($("#p_1").val());
}
</script>
</head>
<body>
<form id="ff" name="l" method="POST" action="dd.html" >
<input type="text" id="p_1" name="p_1"/>
<input type="text" id="p_2" name="p_2"/>
<input type="button" value="submit" onclick="callOperation();"/>
</form>
</body>
</html>