それが基本的に私のスクリプトです。どうして?
[ダウンロード]をクリックした後にテキストを追加したいspan
。
これを試して:
$("li").click(function(o) {
$(this).find('span').text("some text");
});
フィドル - http://jsfiddle.net/TLpSJ/
これでうまくいきます
$(".className").click(function() {
$(".className").next("span").html("some text");
});
$(".className").click(function() {
$(this).next("span").html("some text");
});
このコードを試してください。
$ を使用してクラスごとにセレクターを検索する場合、「.」が必要です。クラス名の前。また、$(".className").next("span").html("some text") と書くと、$(".className") であるため、.className の後のすべてのスパンに「some text」が追加されます。この場合、class="className" を持つ要素の配列になります。
$(".className").click(function(e) {
$(e.currentTarget).next('span').html("some text");
});