편집 : 작동하지만 확실하지 않은 이유는 무엇입니까?jquery - 각/클릭 기능이 작동하지 않습니다.
$('button').each(function() {
$(this).bind(
"click",
function() {
alert($(this).val());
});
});
이 지금, 난 그냥 출력 버튼 값 경고를하려고 해요 ... 작동하지 않는 이유는 잘 모르겠지만, 내 페이지에서 작동하지 않습니다. Firebug에서 콘솔 오류가 발생하지 않으며 작동하지 못하게하는 어떤 것도 볼 수 없습니다.
<table id="addressbooktable">
<thead>
<tr>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>7892870</td>
<td><button id="button-20" class="custom-action" value="XY89" name="info">Click</button></td>
</tr>
<tr>
<td>9382098</td>
<td><button id="button-21" class="custom-action" value="XY544" name="info">Click</button></td>
</tr>
<tr>
<td>3493900</td>
<td><button id="button-22" class="custom-action" value="XY231" name="info">Click</button></td>
</tr>
</tbody>
</table>
을 그리고 코드는 다음과 같습니다 :
내 HTML은 다음과 같습니다 전혀 아무것도하지 않는 클릭,
$('button').each(function() {
$(this).click(function() {
alert($(this).val());
}
});
그러나? 내가 잘못 사용하고 있습니까?
문제가 아니라,하지만 당신은 .each 필요하지 않습니다, 당신은 할 수 하나 이상의 노드가있는 jQuery 객체에서 .click을 사용하면 모두 바인딩됩니다. – Shurdoof
답을 표시 하시겠습니까? – hunter