编辑:这有效,但不知道为什么?
$('button').each(function() {
$(this).bind(
"click",
function() {
alert($(this).val());
});
});
Run Code Online (Sandbox Code Playgroud)
我不确定为什么这不起作用...现在,我只是尝试使用按钮值输出警报,但它不能在我的页面上工作.我没有在Firebug中得到任何控制台错误,也看不到任何阻止它工作的东西.
我的HTML看起来像这样:
<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>
Run Code Online (Sandbox Code Playgroud)
代码看起来像这样:
$('button').each(function() {
$(this).click(function() {
alert($(this).val());
}
});
Run Code Online (Sandbox Code Playgroud)
但是,点击它什么都不做?我使用不正确吗?
我试图获取某个div中的所有输入元素,但它似乎返回任何给定页面上的所有输入...有没有办法做到这一点?
if($('#umi-form')) {
var inputs = document.getElementsByTagName('input');
}
Run Code Online (Sandbox Code Playgroud) 在我的表中,日期存储如下:2011-03-03T13:30:00
我正在尝试输出这样的日期:2011年3月3日下午1:30
我宁愿把它用在查询中,而不是使用php来格式化它,但我在做这件事时遇到了一些困难.尝试DATE_FORMAT的各种迭代,但它没有给我我想要的东西,也许是因为它的存储方式?