嘿,我想从 jquery 中的函数传递一个参数,但我无法让它工作。我究竟做错了什么?我想将点击函数中的“名称”传递给对话框块函数以防止重复代码
更新:我在函数之后定义了名称。但是我仍然不能像这样传递它 <%=GetUserName(name)%>
更新 2 jsFiddle 链接 http://jsfiddle.net/bbKw8/
<div id="dialog-block" >
<p>
<b>Friends List:</b>
<% =GetFriends(0) %>
</p>
</div>
<div id="Div1">
<p>
<b>Friends List:</b>
<% =GetFriends(0) %>
</p>
</div>
<script type="text/javascript">
// the jQuery document ready handler
$(function () {
var name;
// create our dialog
$('#dialog-block').dialog({
title: '<%=GetUserName(name)%>',
autoOpen: false,
width: 400,
buttons: {
"Close": function () {
closeDialog($(this))
}
}
});
// the button to open the dialog
$('#user0chair,#apDiv1').click(function (event) {
if (this.id == 'user0chair') {
$('#dialog-block').dialog('open');
name = 1;
}
else if (this.id == 'user1chair') {
$('#dialog-block').dialog('open');
}
});
});
function closeDialog(elem) {
elem.dialog("close");
}
</script>