如何点击此课程ui-icon-close
?
我有以下HMTL
<ul id="tabs" class="nav nav-tabs" >
<li class="active">
<a href="#List" data-toggle="tab">My List
<span class='ui-icon ui-icon-close'></span>
</a>
</li>
</ul>
以下Jquery / Javascript
$('#tabs a').delegate( "#.ui-icon-close", "click", function(){
console.log('tabs');
});
答案 0 :(得分:3)
<强> Working fiddle 强>
#
#.ui-icon-close
中的额外".ui-icon-close"
应为$('#tabs a').delegate( ".ui-icon-close", "click", function(){
console.log('tabs');
});
:
on()
从jQuery 1.7开始,.delegate()已被.on()方法取代。
因此,您应该使用delegate()
代替click
并反转事件.ui-icon-close
和选择器$('#tabs a').on( "click", ".ui-icon-close", function(){
console.log('tabs');
});
的位置:
var mongo = require('mongodb').MongoClient;
var DB = null;
var dbURL = 'mongodb://localhost:27017';
exports.connect = function(cb) {
console.log('meep'); //tracing code
mongo.connect(dbURL, function(err, db){
console.log('lmao'); //tracing
if (err) throw Error('Something has went wrong');
else { DB=db; console.log(DB); cb();}
});
console.log(DB); //returns null
};
//if some other file requires this file as mydbjs for example,
//I want to be able to do mydbjs.db().collection('epik').find();
exports.db = function() {
if (DB === null) throw Error('DB Object has not yet been initialized');
return DB;
};
希望这有帮助。