开发者

using qtip to replace ALL title attributes on a page

If there a way to have all title attributes become qtips?

Right now I'm just going through and finding all the tags that need to be done but this is slow and not reliable.

instead of this

$(document).ready(ImportantFunction);
    function ImportantFunction() {
        Sys.Application.add_load(function () {
            $find("ctl31").add_propertyChanged(viewerPropertyChanged);
        });
    }

    function viewerPropertyChanged(sender, e) {
        if (e.get_开发者_StackOverflow中文版propertyName() === "isLoading") {
            var viewer = $find("ctl31");
            if (!viewer.get_isLoading())
            {
                $('table[title]').qtip();
                $('td[title]').qtip();
                $('input[title]').qtip();
                $('a[title]').qtip();
            }
        }
    }//*/

I just want to call it once if that is possible.


Pretty easy:

$('[title]').qtip();


How about using $.each() instead? It probably seems trivial and similar but it also may go faster since you're only calling qTip on a (hopefully) smaller subset:

  $('[title]').each(function() {
      this.qtip({
           // init here
      });
 });

Note that you can also comma-separate your selectors, so you could simply do:

  $('table[title],td[title],input[title],a[title]').each(function() {
      this.qtip({
           // init here
      });
 });

Or even:

  $('table[title],td[title],input[title],a[title]').qtip();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜