編集可能な iframe で imgs を選択していくつかのアクションを実行する必要があります。私はすべての画像でそれを行うことができます(たとえば、ここにコードがあります)
$(iframe).contents().find('img').attr('alt', 'new alt')
が、ユーザー選択内の img のみが必要です。お願い助けて。ありがとう
2 に答える
1
ユーザーがコードの取得を選択して、ユーザーの選択範囲内の画像に選択クラスを追加する場合
//inserted within your selection method
$(iframe).contents().find('img').removeClass('selectionClass');
//this removes all previously selected images
//unless you have a deselection method in which case you don't need this,
//you would need to add $(this).removeClass('selectionClass') to the deselection
$(this).addClass('selectionClass');
//adds it to currently selected images
次に、編集する画像を選択するときに次を使用します。
$(iframe).contents().find('img.selectedClass').attr('alt', 'new alt');
于 2012-07-30T11:58:03.753 に答える
0
タグにIDを付けて、jQueryを使用して呼び出し、alt属性を設定してみませんか。例えば:
<img id="myImageId"/>
$("#myImageId").attr("alt","This is an image!");
于 2012-07-30T12:01:10.477 に答える