jquery trigger伪造a标签的click事件取代window.open方法_Javascript教程-查字典教程网
jquery trigger伪造a标签的click事件取代window.open方法
jquery trigger伪造a标签的click事件取代window.open方法
发布时间:2016-12-30 来源:查字典编辑
摘要:varohtml=''+'您已经成功发送好友申请。'+'上传真实头像,好友申请更容易被通过哦,赶紧上传头像吧!'+''+'';$.dialo...

var ohtml='<div>'+ '<div>您已经成功发送好友申请。</div>'+ ' <p>上传真实头像,好友申请更容易被通过哦,赶紧上传头像吧!</p> '+ '<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a>'+ ' </div>'; $.dialog({ lock:true, title: '温馨提示', button: [ {value: '点击上传图像',callback: function () { $("#awindowopen").trigger("click"); },focus: true } ], content:ohtml }); var ohtml='<div>'+ '<div>您已经成功发送好友申请。</div>'+ ' <p>上传真实头像,好友申请更容易被通过哦,赶紧上传头像吧!</p> '+ '<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a>'+ ' </div>'; $.dialog({ lock:true, title: '温馨提示', button: [ {value: '点击上传图像',callback: function () { $("#awindowopen").trigger("click"); },focus: true } ], content:ohtml });

需要注意的是:

在这个地方:

<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a> <a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a> <a>标签内一定要有内容,并且要模拟里面的内容被点击而不是<a></a>被点击

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类