Reputation: 59
I'm creating a chrome extension, adding a "tab" to a website:
(function () {
$(".tabs").append('<li><a data-toggle="tab" href="#MyNewTab" onclick="MyExtClick()">NEW TAB</a></li>');
}());
Until this point, everything is perfect, but when I tried to add an "onclick" event to the tab, ie: a simple alert with a message, but it didn't work
function MyExtClick(){
alert("This is an alert");
}());
Is that a syntax problem?
Upvotes: 0
Views: 52
Reputation: 2205
EDIT:
have you tried this?
$("a").click(function(e){
alert("This is an alert");
e.preventDefault();
});
or
$("a").live("click", function(e){
alert("This is an alert");
e.preventDefault();
});
If this doesn't work, can you post it on jsfiddle or jsbin so that I can test it?
Upvotes: 1