l have got a series of menus.

What l want to do is change the background-color of the link onclick.

What l have done use jquery like this

jQuery('.menu a').click(function(){
     var clz = jQuery(this).attr('id');
     jQuery(this).attr('class','active'+clz);
  })

This is not work.The code needs to work on mobile phones

Using 'a:visited' you can set the style for visited links:

/* CSS */
a:visited { background-color: red; }

Is that enough?

Thank you for the reply.

What l need howwever is when u click the background changes something like the iphone otouchstart trigger

Then you need to write an event handler in JS. Three steps.

1) give the trigger an id, use it to get the element
2) write a function that handles the event
3) assign the function to the trigger element's 'onclick'

var trigger_ref = document.getElementById( 'trigger_element' );

function handle_trig_click() {
    /* code here to respond to the click. 'this' is the trigger element. */
}

trigger_ref.onclick = handle_trig_click; // NOTE: NO PARENS!

I always start the onclick function with just an alert:

function handle_trig_click() {
    alert( 'Hey! I'm in handle_trig_click()!' );
}

That way you don't waste hours trying to debug a function that isn't called.

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.