0

我在看:CoolInput,但我需要一个 destroy 方法。

我希望能够做这样的事情:

$('#manualhint2').coolinput('foobar');

但我还需要一种方法,例如:

$('#manualhint2').coolinput(destroy);  

或类似的东西,因为有时我需要禁用 CoolInput。

有人能帮帮我吗?
或者,您也可以推荐另一个具有destroy 方法的jquery 提示库。

谢谢!

4

2 回答 2

2

你有没有尝试过

$('#manualhint2').coolinput(''); 

?

于 2010-04-19T14:36:33.280 回答
1

通过对 CoolInput 代码进行一些探索,我得到了这个:

$(selector).each(function () {
  EmptyThisCoolInput($(this));
});

function EmptyThisCoolInput(o) {
  try {
    if (o.val() == o.attr(coolInputAttribute) && o.hasClass(coolinputBlurClass))
      o.val("").removeClass(coolinputBlurClass);
  } catch (e) { }
}

我分开EmptyThisCoolInput是因为我把它叫做别的地方。您可以安全地使用以下语法:

$(selector).each(function () {
  try {
    if ($(this).val() == $(this).attr(coolInputAttribute) && $(this).hasClass(coolinputBlurClass))
      $(this).val("").removeClass(coolinputBlurClass);
  } catch (e) { }
});
于 2012-02-20T23:31:46.517 回答