Reputation: 1209
$(document).ready(function(){$("[href]").appendTo(" Click here ...");});
HTML Code
<a href="#"> b </a>
I want to to show it on browser as b Click here ... But i didn't work properly here.
Upvotes: 1
Views: 1147
Reputation: 22323
Use ID insted of tag.If you have multiple anchor tag its work for all.
$(document).ready(function(){
$("#YourID").append(" Click here ...");
});
<a href="#" id="YourID"> b </a>
Upvotes: 0
Reputation: 14983
have you tried append instead of appendTo ?
$(document).ready(function(){$("[href]").append(" Click here ...");});
from my understanding it works like:
element.append('stuff to append to the element');
vs
element.appendTo(otherElement);
Upvotes: 1
Reputation: 20860
Try this.
$(document).ready(function(){
$("[href]").append(" Click here ...");
});
Use .append() function instead of .appendTo() function.
Here is the demo
Upvotes: 1
Reputation: 2164
I think you are looking for append()
rather than appendTo()
.
append()
simply takes the text or jQuery element that you supply as an argument and appends it as the last child of the element that you have selected - I think this is the behavious you are looking for. The documentation for append()
is at http://api.jquery.com/append/ if you want to look into it more.
Upvotes: 0
Reputation: 9080
Change:
$("[href]").appendTo(" Click here ...");
To:
$("[href]").html(" Click here ...");
With appendTo
, you are supposed to add a new DOM element not text node.
Upvotes: 0
Reputation: 13753
Use direct tag selector and also append
method
$(document).ready(function(){
$("a").append(" Click here ...");
});
Upvotes: 1