1

の中にいくつかのformattedテキストがtextareaあり、カーソルがどこかにあります。カーソルが特定のタグの間にあるかどうかを確認する必要があります。

例: foo|バー.

isBetween(['b', 'strong']); // should return true in above case

内部のfunction返品がpositionあります(いくつか問題がありますが、今のところ満足しています)。だから、私が必要なのはそれだけです。cursortextareaIEisBetween() function

助けてくれてありがとう!

更新

<p>qwer<b>ty|ui</b>op</p>
isBetween(['p']); // should also return true, because the cursor in not only between 'b', it is between 'p' too
4

1 に答える 1

1

 タグ間のスペースをタグで囲む必要がありますspan。次に、jQuery で.mouseover()関数を使用します。

例:

<b>TAG1</b>
<span id="spacer">&nbsp;</span>
<strong>TAG2</strong>

<script type="text/javascript">
    $("#spacer").mouseover(function(){
        //Do stuff
    });
</script>

スパンには何かが含まれている必要があるため&nbsp;、そこに をスペースとして挿入します。

ライブ フィドルの例: http://jsfiddle.net/PrruT/

アップデート:

すべての機能を実行するつもりはありませんが、次のように設定できることをお伝えします。

/* I'm assuming you can figure out how to get the cursor position on your own, represented by var cursor */

function isBetween(selectorOne, selectorTwo){
    var left = $(selectorOne).position().left; //Left position of the object
    var right = $(selectorTwo).position().left + $(selectorTwo).width(); //Right XY position of the object
    if (cursor > left && cursor < right)
        return true;
    else
        return false;
}
于 2012-09-03T14:30:33.827 に答える