简体   繁体   English

将jQuery选择器添加到javascript对象

[英]Add jQuery selector to javascript object

I have a javascript object as below . 我有一个如下的javascript对象。 i'm using bootstrap 3 for modal object. 我正在为模态对象使用bootstrap 3。 the problem is i cannot access the real modal object inside the 'displayModal' method 问题是我无法在“ displayModal”方法内访问实际的模态对象

  var modalHandler = { modal: $(".modal"), modalBody: $(".modal").find(".modal-body"), displayModal: function(){ this.modalBody.text("bla bla"); } } modalHandler.displayModal(); 

Try this, 尝试这个,

displayModal: function(){
   $(this.modalBody).text("bla bla");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM