Javascript $(this.attr(';id';)在jQuery中提供空值

Javascript $(this.attr(';id';)在jQuery中提供空值,javascript,jquery,html-framework-7,Javascript,Jquery,Html Framework 7,我有一个链接如下: <a href="#" id="<?php $res['id'];?>" class='bid_accept'>Accept</a> $$('.bid_accept').on('click', function (e) { e.preventDefault(); var value = $(this).attr('id'); var jsonstring = JSON.stringify(value); myApp.confirm('Ar

我有一个链接如下:

<a href="#" id="<?php $res['id'];?>" class='bid_accept'>Accept</a>
$$('.bid_accept').on('click', function (e) {
e.preventDefault();
var value = $(this).attr('id');
var jsonstring = JSON.stringify(value);
myApp.confirm('Are you sure?', 'Custom Title', 
function (jsonstring) {
myApp.alert('Your name is "' + value + '". You clicked Ok button');
   },
function () {
myApp.alert('You clicked Cancel button');
   }
  );
});      
我收到的警报如下:

您的名字是“。您单击了“确定”按钮

我还尝试:

var value = this.id;

为什么我没有得到
id
值?

如果你使用
JSON.stringfy(value)
这意味着你是从一个JSON值中设置该id,我不知道我是否在写,但是id属性取一个单词名,并且
JSON.stringfy()
生成多个用空格分隔的单词。更不用说我认为ID有特定数量的字符,所以您可能会初始化一个很长的名称。 不确定您想要实现什么,但HTML允许您添加自己的属性,并在JQuery中读取它们,如:

<a href="#" myAttr="<?php $res['id'];?>" class='bid_accept'>Accept</a>
这行有错误

<a href="#" id="<?php $res['id'];?>" class='bid_accept'>Accept</a>

因为您的id attibute为空:)您缺少
id=”“
@php-dev中的
echo
语句是的,我以前试过。我明白了:你的名字是“[对象]”。您单击了“确定”按钮。但是我使用了JSON.stringify???请发布呈现的HTML,而不是PHP,这样我们可以看到ID是什么,并在代码段中重新创建问题。另外,双美元登录
$$('.bid_accept')
有什么用?我想您的属性是空的。id是一个动态值。$$符号是特定于框架7的。
<a href="#" id="<?php $res['id'];?>" class='bid_accept'>Accept</a>
<a href="#" id="<?php echo $res['id'];?>" class='bid_accept'>Accept</a>
var value = $$(this).attr('id'); // check $$ sign