我想调用显示在
下的 my()功能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>
因为如果来电是 id ,那就是 #element , 形式的行为不起作用。
答案 0 :(得分:0)
您不需要绑定onclick并且还可以调用onclick来执行某些操作。 只是这样做
<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>