Replacing a content of an anchor with jQuery
Page 1 of 1
dingo_d
VIP Member



Posts: 14555

PostPosted: Wed, 14th May 2014 16:44    Post subject: Replacing a content of an anchor with jQuery
I have an anchor that looks like this:

Code:
<a class="slidesjs-previous slidesjs-navigation" href="#" title="Previous">Previous</a>


I want it to look like this:

Code:
<a href="#" class="slidesjs-previous slidesjs-navigation"><i class="icon-chevron-left icon-large"></i></a>


there is actualy ::before bewteen <i></i> tags.

Now from what I remember I could do this by pointing at a class and using .html()

So I made a simple script inside my html

Code:
  <script type="text/javascript">
  $(document).ready(function(){
   $("a.slidesjs-previous").html("<i class="icon-chevron-left icon-large">::before</i>");
   $("a.slidesjs-next").html("<i class="icon-chevron-right icon-large">::before</i>");
  });
  </script>


But nothing happens. I get an 'Uncaught SyntaxError: Unexpected identifier' error :\

What did I miss? :\


"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson
chiv wrote:
thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found.

Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 14th May 2014 16:48    Post subject:
Well of course you get that error because look at your " <-

Here it's fixed:
Code:

   $("a.slidesjs-previous").html("<i class='icon-chevron-left icon-large'>::before</i>");
   $("a.slidesjs-next").html("<i class='icon-chevron-right icon-large'>::before</i>");

You just broke the code by using the same quotation marks inside your string.


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
dingo_d
VIP Member



Posts: 14555

PostPosted: Wed, 14th May 2014 16:55    Post subject:
Oh that's right! Quotation :S I forgot about that! Thanks Pumpy Smile


"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson
chiv wrote:
thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found.

Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 14th May 2014 17:27    Post subject:
You know my bank details Cool Face


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
dingo_d
VIP Member



Posts: 14555

PostPosted: Wed, 14th May 2014 18:47    Post subject:
Well with the amount of help I've got from you over the years... When I get a job I'll send you some token of gratitude Smile


"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson
chiv wrote:
thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found.

Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 14th May 2014 23:34    Post subject:
Your first born So Much Win ... wait Scratch Head

LOL


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
dingo_d
VIP Member



Posts: 14555

PostPosted: Thu, 15th May 2014 09:47    Post subject:
Laughing If I have a child you can gladly take it xD


*don't plan on having children* Poker Face


"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson
chiv wrote:
thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found.

Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group