Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
How should I pass a value through JQuery on HTML page by anchor tag
for ex.
HTML
<a href="" id="">hi</a>
<a href="" id="">all</a>

I just want to print 'hi all' on span
HTML
<span></span>
Posted

1 solution

Edit your html code like -
HTML
<a href="" id="link1">hi</a>
<a href="" id="link2">all</a>
...



JavaScript
<!-- Add your jquery.min.js file path here -->
<script type="text/javascript">
$(document).ready(funcyion(){
 
   $(".outputSpan").text($("#link1").text()+" "+$("#link2").text());
   
});
 
</script>
 
Share this answer
 
Comments
project virus 31-Aug-13 2:11am    
thanks for the answer..I have one more que. How can we pass value using address using jquery.for ex.
<pre Language="HTML"><a href="#contactFormContainer" class="contact bottomlink" address="AB-Rocket">More Question
if I want to print more question?
Anand Kumar Prajapati 31-Aug-13 2:19am    
$(".contact.bottomlink").attr("address").val("Give your value here!")

Please don't forget to mark this solution as Answer. If it helps you :)
project virus 31-Aug-13 2:31am    
yes.but wait I have one more que.Can we use class instead of id..Because I want to use multiple href for same function.like
a href="" id="link1" class="linked" hi /a
$(".outputSpan").text($(".linked").text());
Anand Kumar Prajapati 31-Aug-13 9:13am    
use this -
var txt="";
$(".linked").each(function(){
txt=
$(".outputSpan").text()+" "+$(this).text();

$(".outputSpan").text(txt);
});
project virus 31-Aug-13 2:34am    
i tried but nothing is happened.is there any alternate solution for multiple href of same classes...?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900