将函数绑定到jquery中的html元素 [英] binding a function to html element in jquery
本文介绍了将函数绑定到jquery中的html元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
code $(this._element).append('< input type =buttonvalue =closeonclick ='+ obj +'。quit('+ obj._roomid +');/>' );
无法正常工作。当我按下以下代码中的按钮关闭时,我可以调用函数退出
code $(this._element).append('<input type="button" value="close" onclick="'+obj+'.quit('+obj._roomid+');"/>');
is not working .how can i call function quit when pressing button close in below code
Box.prototype = {
get_title: function () {
return this._title;
},
set_title: function (val) {
this._title = val;
},
get_roomid: function () {
return this._roomid;
},
set_roomid: function (val) {
this._roomid = val;
},
open: function (RoomId, RoomName) {
if ($.inArray(RoomId, lockBox) == -1) {
this._roomid = RoomId;
this._title = RoomName;
this._element = document.createElement("DIV");
this._element.style.display = "none";
this._iframe = document.createElement("IFRAME");
this._iframe.src = "chatbox.aspx?i=" + RoomId;
this._iframe.style.width = "800px";
this._iframe.frameBorder = 0;
this._iframe.style.height = "360px";
this._iframe.scrolling = "no";
this._element.appendChild(this._iframe);
document.body.appendChild(this._element);
$(this._element).append('<input value="close" type="button" onclick="'+obj+'.quit('+obj._roomid+');"/>');
var obj = this;
$(this._element).show();
lockBox.push(RoomId);
$addHandler(window, "unload", function () {
obj.quit(obj._roomid);
});
$("#_cu_" + RoomId).html(Number($("#_cu_" + RoomId).html()) + 1);
}
else {
ShowMessageBox("Exception", "You have joined the chat room");
}
},
quit: function (roomid) {
ShowMessageBox("Leave Chat Room", "Please waiting...");
csaspnetajaxwebchat.transition.LeaveChatRoom(roomid, function () {
lockBox = $.map(lockBox, function (n) {
return n != roomid ? n : null;
});
$("#_cu_" + roomid).html(Number($("#_cu_" + roomid).html()) - 1);
CloseMessageBox();
});
},
test: function (roomid) {
alert(roomid);
}
}
推荐答案
(this._element).append('< input type =button value =closeonclick ='+ obj +'。quit('+ obj._roomid +');/>');
无法正常工作。当我按下以下代码中的按钮关闭时,我可以调用函数退出
(this._element).append('<input type="button" value="close" onclick="'+obj+'.quit('+obj._roomid+');"/>');
is not working .how can i call function quit when pressing button close in below code
Box.prototype = {
get_title: function () {
return this._title;
},
set_title: function (val) {
this._title = val;
},
get_roomid: function () {
return this._roomid;
},
set_roomid: function (val) {
this._roomid = val;
},
open: function (RoomId, RoomName) {
if (
.inArray(RoomId,lockBox)== -1){
this ._ roomid = RoomId;
此 ._ title = RoomName;
此 ._ element = document.createElement( DIV跨度>);
此 ._ element.style.display = 无 跨度>;
此 ._ iframe = document.createElement( IFRAME跨度>);
此 ._ iframe.src = chatbox .aspx?i = + RoomId;
此 ._ iframe.style.width = 800像素跨度>;
此 ._ iframe.frameBorder = 0 ;
此 ._ iframe.style.height = 360像素跨度>;
this ._ iframe.scrolling = no 跨度>;
此 ._ element.appendChild(此 ._ iframe);
document.body.appendChild( this ._ element);
.inArray(RoomId, lockBox) == -1) { this._roomid = RoomId; this._title = RoomName; this._element = document.createElement("DIV"); this._element.style.display = "none"; this._iframe = document.createElement("IFRAME"); this._iframe.src = "chatbox.aspx?i=" + RoomId; this._iframe.style.width = "800px"; this._iframe.frameBorder = 0; this._iframe.style.height = "360px"; this._iframe.scrolling = "no"; this._element.appendChild(this._iframe); document.body.appendChild(this._element);
( this ._ element).append(' < input value =closetype =buttononclick =' + obj + ' 。quit(' + obj。 _roomid + ' );/>');
var obj = this ;
(this._element).append('<input value="close" type="button" onclick="'+obj+'.quit('+obj._roomid+');"/>'); var obj = this;
这篇关于将函数绑定到jquery中的html元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文