3

を使用して画像を動的にロードできることを知っています

$("#id").attr("src","path of the image"),

しかし、特定のイベントで特定の画像をオンロードするには、

$("id").attr("src","")

動作しません。

jquery を使用してイメージ ランタイムをアンロードする正しい方法は何ですか??

画像の表示または可視性プロパティを変更できません。ロードしてアンロードする必要があります。

4

4 に答える 4

9

これを行うにはいくつかの方法があります。自分に合ったものを使えます

  1. $('#id').removeAttr('src');​ // Remove the src
  2. $('#id').remove(); //This will remove the element from DOM so be careful
  3. $('#id').attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='); // This will change the src to a 1x1 pixel

  4. $('#id').removeAttr('src').replaceWith($image.clone()); //That worked for few people

于 2016-03-21T10:43:59.550 に答える
0

IDを使用して要素を削除するだけです。

$("#id").remove();
于 2013-02-21T18:32:51.813 に答える