As written your code works. So there must be another reason for it not working.
Either the DOM isn't ready in which case wrap the click handler in the DOM ready callback
$(function(){
// register event handler for delcomment
$( "span.delcomment" ).click(function() {
// some code that actually deletes comment from database
});
});
Or these elements are being added dynamically, in which case you would delegate the click event to that specific class
// register event handler for delcomment
$( "body" ).on("click", "span.delcomment", function() {
// some code that actually deletes comment from database
});
This delegation works by assigning a handler to the body element itself, and then every time a click event is registered, it looks to see if the target element matches the given selector. If it does, then the callback function is called (and internally .bind
is used to make that target element equal to this
in the callback).
I have created two functions that run a similar set of IF statements, one shows the cost of a game, the other its name. I have used "onclick" to display both values in my form. It all works but ...
I have created two functions that run a similar set of IF statements, one shows the cost of a game, the other its name. I have used "onclick" to display both values in my form. It all works but ...
I'm new to Mocha and I'm trying to run the tests on this code: "use strict"; process.env.NODE_ENV = 'test'; var assert = require('assert'), Browser = require('zombie'), xapp = require('../...
I'm new to Mocha and I'm trying to run the tests on this code: "use strict"; process.env.NODE_ENV = 'test'; var assert = require('assert'), Browser = require('zombie'), xapp = require('../...
I've been trying to push a complex json data record into a json variable. This is the code I tried to do so. var marks=[]; var studentData="student1":[{ "term1":[ {"LifeSkills":[{...
I've been trying to push a complex json data record into a json variable. This is the code I tried to do so. var marks=[]; var studentData="student1":[{ "term1":[ {"LifeSkills":[{...
Can I center the content of div with center-block?? The following example does not work: <div class="form-group"> <div class="center-block"> <input id="...
Can I center the content of div with center-block?? The following example does not work: <div class="form-group"> <div class="center-block"> <input id="...