如何在使用html5在java中单击时单击超链接文本值。 [英] how to get clicked hyperlinks text value when clicked in java using html5.
本文介绍了如何在使用html5在java中单击时单击超链接文本值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的jsp页面中有很多超链接。无论点击哪个链接,我都希望将其文本存储在变量中。然后传递该变量。
out.println(< a href = \ '+ webTempPath + '/ 1.mp3 \ > );
out.println(files);
out.println(< / a > );
我已经使用aboe代码获取了文本值并使其成为链接。因为我有很多我想要的链接,无论点击哪个链接我想要播放。
而不是1.mp3链接的文本传递。任何人都可以帮助我out。
解决方案
这是客户端问题,只需使用JavaScript或jQuery即可。从此示例代码改编:
< html >
< head >
< 脚本 src = https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js > < / script >
< script > ; 跨度>
(文件)。就绪(函数(){
( 链接)上(点击,a,function(e){
e.preventDefault(); //取消重定向
var txt =
I have many hyperlinks in my jsp page. Whichever link is clicked I want to store it's text in a variable. And then pass that variable.
out.println("<a href=\"'+ webTempPath + '/1.mp3\">");
out.println(files);
out.println("</a>");
I have fetched the text values and made them links using the aboe code. As I have many links I want, whichever link is clicked I want that to be played.
instead of 1.mp3 that link's text to passed.Can anyone help me out.
解决方案
This is client-side matter, just use JavaScript or jQuery will do. Adapt from this sample code:
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>
(document).ready(function(){
("links").on("click", "a", function(e){ e.preventDefault(); // cancel redirecting var txt =
这篇关于如何在使用html5在java中单击时单击超链接文本值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文