0

各 URL の横に 4 つのボタンが必要です。ボタンをクリックして、親 URL をボタンのそれぞれのテキストフィールドにコピーできます。

jquery を使用してこれを行うのが最も簡単だと思いますが、どこから始めればよいかわかりません。どんなアドバイスでも大歓迎です!

http://jsfiddle.net/WwdMw/

<div class="selection">
  <div class"url">
    <h2>example1.com</h2>
  </div>
  <button type="button" class="btn_opt1">Copy to Option1</button>
  <button type="button" class="btn_opt2">Copy to Option2</button>
  <button type="button" class="btn_opt3">Copy to Option3</button>
  <button type="button" class="btn_opt4">Copy to Option4</button>
</div>
<hr/>
<div class="selection">
  <div class"url">
    <h2>example3.com</h2>
  </div>
  <button type="button" class="btn_opt1">Copy to Option1</button>
  <button type="button" class="btn_opt2">Copy to Option2</button>
  <button type="button" class="btn_opt3">Copy to Option3</button>
  <button type="button" class="btn_opt4">Copy to Option4</button>
</div>
<hr/>

<div class="selection">
  <div class"url">
    <h2>example2.com</h2>
  </div>
  <button type="button" class="btn_opt1">Copy to Option1</button>
  <button type="button" class="btn_opt2">Copy to Option2</button>
  <button type="button" class="btn_opt3">Copy to Option3</button>
  <button type="button" class="btn_opt4">Copy to Option4</button>
</div>

<hr/>
4

1 に答える 1

1

それを持っている。

$('button').click(function () {
    var value = $(this).parent().find('h2').text();
    var idIdentifier = $(this).text().substr($(this).text().length - 1);
    var textArea = $('div[class*='+idIdentifier+']').find('textarea');
    textArea.val(textArea.val() +" "+ value);
})

ライブデモ

于 2013-10-24T17:10:13.257 に答える