jquery赋值

     var ab = $(this).attr("tumb");
                var as = "$Site.url$class/view{suffix}?id="+ab;
                $('div.gallery_list_index_he a').attr('href','"+as+"');

想把as赋值给href,但一直没成功,怎么写才是对的

阅读 2.7k
3 个回答

$('div.gallery_list_index_he a').attr('href','+'+as+'+');

$('div.gallery_list_index_he a').attr('href',as);

引号使用有误:

var ab = $(this).attr("tumb");
var as = "$Site.url$class/view{suffix}?id=" + ab;
$('div.gallery_list_index_he a').attr('href', as); //这样可以,as本身就是个字符串了
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题