我正在使用JQuery标签。点击后,我试图只显示一条警告信息(并进行一些着色更改)。两者都不起作用 - 我不确定为什么当我将它从标签部分移动到常规html时它完美地工作。这是相关的代码:
来自Jquery Tabs的addTab():
tabContentHtml = "<div class=\"favorite\" status=\"off\">☆</div>"
我自己的javascript代码:
$(".favorite").click(
function(){
alert("in here");
var current_status = $(this).attr("status");
if(current_status == "off"){
$(this).html("★");
$(this).css({"color":"gold"});
$(this).attr("status", "on");
}else if (current_status == "on"){
$(this).html("☆");
$(this).css({"color":"#EFEFEF"});
$(this).attr("status", "off");
}
}
);
请注意,我确实在标签中看到了星标,它只是没有响应!
答案 0 :(得分:2)
jQuery UI标签有没有 click
方法。相反,它被称为 activate
方法,
$(function () {
$("#tabs").tabs({
activate: function (event, ui) {
alert("I'm triggered"); //Within this you can wtite ToDos
}
});
});