trying to use the preferred on method call but the code is not working with on but does work with the live method.
Okay, I have a simple button element.
<button id="EditVal" name="EditVal" style="btn" value="Edit Debt">Edit Debt </button>
If I use the live method this code works:
$("#EditVal").live("click", function(e){
alert('Edit this Val');
})
But this doesn’t
$("#EditVal").on("click", function(e){
alert('Edit this Val');
})
What am I doing wrong?
If your dynamically dropping a html element on the page then you need live. Here is why, on is set to work on EditVal if EditVal exsists on pageload. Since it does not I am assuming, the live function is needed as that can be bounded late after the initial page load. I think that was the original thought behind live in the first place. Any particular reason why you are using on instead of live?