最初のボタン onclick だけがトリガーされるのはなぜですか? i 2つの他の人は、クリックしてもイベントをトリガーしません。また、コンソールにエラーはありません:
<script>
$(document).ready(function(){
var name_of_sender ="";
var text_of_sender ="";
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$("#edit_text").click(function() {
var butName = $(this).attr("name");
var user_id = butName.split("_")[1];
alert(user_id);
name_of_sender = $('#username_'+user_id).html();
text_of_sender = $('#text_'+user_id).html();
alert(name_of_sender);
alert(text_of_sender);
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
</script>
<table>
<tbody>
<tr>
<td id="username_33">test</td>
<td id="text_33">asdasdasd</td>
<td>2012-09-27</td>
<td>217.xx.xx.6</td>
<td>
<button id="edit_text" name="id_33">Edit</button>
</td>
</tr>
<tr>
<td id="username_34">test</td>
<td id="text_34">asdasdasd</td>
<td>2012-09-27</td>
<td>217.xx.xx.6</td>
<td>
<button id="edit_text" name="id_34">Edit</button>
</td>
</tr>
<tr>
<td id="username_35">test</td>
<td id="text_34">asdasdasd</td>
<td>2012-09-27</td>
<td>217.xx.xx.6</td>
<td>
<button id="edit_text" name="id_35">Edit</button>
</td>
</tr>
</tbody>
</table>