JQuery 将变量解析为 onclick
我编写了一些 Jquery 来添加带有单击事件的图像,但我正在努力让单击事件提醒我创建的函数,这里的最终目标是构建一个使用 LookURL 变量的 window.open 事件作为它的地址。
为了节省在问题中放置大量代码,我在下面创建了一个 JS Fiddle。
I have a bit of Jquery written to add an image with an on click event but I am struggling to get the on click to alert the function that I have created the ultimate aim here is to build a window.open event that uses the lookURL variable as its a address.
To save placing loads of code in the question i have created a JS Fiddle below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全有信心知道您要做什么,但如果您只想将
lookURL
变量放入click()
时执行的函数中code> 已运行,这非常简单: http://jsfiddle.net/XcAHx/我已经采取了
点击
脱离 HTML 并进入它自己的函数,在那里您可以引用lookURL
变量:这就是您想要的吗?
I'm not entirely confident I know what you're trying to do but if all you want to do is get the
lookURL
variable into the function that is executed when theclick()
is run, it's pretty easy: http://jsfiddle.net/XcAHx/I've taken the
onClick
out of the HTML and into it's own function, and in there you can just reference thelookURL
variable:Is that what you were after?
您已经完成了大部分工作,只需更改
为
修改后的jsfiddle示例
You've done most of the work, just change
to
modified jsfiddle example