3

このポップオーバーを適用したい

$('.body').popover({
  html: true,
  trigger: 'hover',
  placement: 'top',
  container: 'body',
  content: function () {
    return '<img src="'+$(this).attr('href') + '" />';
  }
});

場合のみ/(jpg|gif|png)$/.test($(this).attr('href'))

これを行う方法がわかりません..前に条件を実行できないため、すでにポップオーバー内にいる場合は手遅れです

4

2 に答える 2

0

私はフィルターを使用してそれをフィルタリングすることになりました

$('.body').filter(function() {
  return /(jpg|gif|png)$/.test($(this).attr('href'))
}).popover({ html: true,
            trigger: 'hover',
            placement: 'top',
            container: 'body',
            content: function () {
                return '<img src="'+$(this).attr('href') + '" />';
             }
            });
于 2013-04-26T16:50:00.980 に答える