我想获得复选框的属性值的值.我的代码给了我undefined
$('#mytable').find('tr').each(function () {
var row = $(this);
if ( row.find('input[type="checkbox"]').is(':checked') ) {
alert( $(this).attr("b_partner_id") );
}
});
Run Code Online (Sandbox Code Playgroud) 我有两个阵列如图所示
//array 1
Array
(
[0] => 223
[1] => 216
)
/array 2
Array
(
[221] => Bakers
[220] => Construction
[223] => Information Technology
[216] => Jewellery
[217] => Photography
[222] => Retailers
)
Run Code Online (Sandbox Code Playgroud)
我想要第一个数组的键(值)与第二个数组(键)匹配的文本.
预期结果:
Information Technology, Jewellery
Run Code Online (Sandbox Code Playgroud) 我想使用序列化方法完成的ajax发送表单数据但输入类型文本和电子邮件在数组中序列化但输入类型文件不在数组中序列化
<form role="form" action="javascript:;" id="myform" enctype = "multipart/form-data" method = "post">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Name">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="email">Photo:</label>
<input type="file" name="userPhoto" id="userPhoto" class="form-control" />
</div>
<button type="submit" class="btn btn-default submit_add" id="enter">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
和Ajax代码
$('.submit_add').click(function(e){
e.preventDefault();
var data = $('#myform').serialize();
console.log(data); return false;
$.ajax({
url: '/ajax',
type: 'POST',
cache: false,
data: data,
dataType: 'json',
success: function(data) {
if (data.success == …Run Code Online (Sandbox Code Playgroud) 我正在处理一个具有模态的 html 页面,然后如果页面上加载了模态,那么如果我按下 ESC 键,则模态关闭,这对我来说非常不喜欢。如何防止这种情况。?请注意使用 cakephp 渲染的模式。我试过这个,但不工作
$(document).keydown(function(e) {
if (e.keyCode == 27) return false;
});
Run Code Online (Sandbox Code Playgroud)