Jump to content



Photo

Javascript changing A Tag content after click?


  • Please log in to reply
4 replies to this topic

#1 ACTIONpack

ACTIONpack

    Graphic Designer

  • Tech Issues Solved: 1
  • Joined: 10-August 03
  • Location: Lawrenceville, GA
  • OS: Windows 8.1 Pro
  • Phone: Nokia Lumia 925 (T-Mobile)

Posted 05 March 2013 - 08:28

If you go to the "What's the difference between Organic, Eco-Sustainable & Environmental Low Impact Products?" button when you click on it and the div shows in javascript, I would like the down arrow to go up. Not sure how to do it. if you can tell me how to would be great.

http://www.romabio.com/products/


#2 XerXis

XerXis

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 13-February 06
  • Location: Belgium

Posted 05 March 2013 - 08:45

if you use jquery:

$("#linkid").click(function()
{
//do something for click

var thelink = $(this);

//do something with link, for example css background
thelink.css("background", "......");
});

ow yeah, you might want to return false to cancel the link event to the browser. Or if you have several chained events, that might or might not be fired you can use the preventdefault method.

#3 OP ACTIONpack

ACTIONpack

    Graphic Designer

  • Tech Issues Solved: 1
  • Joined: 10-August 03
  • Location: Lawrenceville, GA
  • OS: Windows 8.1 Pro
  • Phone: Nokia Lumia 925 (T-Mobile)

Posted 05 March 2013 - 18:39

Trying to get the down arrrow to an "X". Trying to do a search on it but can't find anything on it.

#4 threetonesun

threetonesun

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 26-February 02

Posted 05 March 2013 - 19:40

Here's a fiddle for it: http://jsfiddle.net/HFgFQ/
HTML:
<a href='#' id='change'>v</a>

JS:
$('#change').click(function(){
   var text = $(this).text();
   text == 'v' ? $(this).text('x') : $(this).text('v');  
   return false;
});


#5 OP ACTIONpack

ACTIONpack

    Graphic Designer

  • Tech Issues Solved: 1
  • Joined: 10-August 03
  • Location: Lawrenceville, GA
  • OS: Windows 8.1 Pro
  • Phone: Nokia Lumia 925 (T-Mobile)

Posted 05 March 2013 - 23:27

Thanks for your help!



Click here to login or here to register to remove this ad, it's free!