Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

javascript - 如何通过<a href...> ... </a>链接进行提交?(How to make a submit out of a <a href…>…</a> link?)

I got an image with which links to another page using <a href="..."> <img ...> </a> .(我有一个图像,使用<a href="..."> <img ...> </a>链接到另一个页面。)

How can I make it make a post like if it was a button <input type="submit"...> ?(我怎样才能让它像一个按钮<input type="submit"...>一样发帖?)

  ask by fmsf translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

More generic approatch using JQuery library closest () and submit () buttons.(更通用approatch使用JQuery的最近的 (),并提交 ()按钮。)

Here you do not have to specify whitch form you want to submit, submits the form it is in.(在这里,您不必指定要提交的表格,提交表格。)
<a href="#" onclick="$(this).closest('form').submit()">Submit Link</a>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...