tags:

views:

32

answers:

1

I use an AJAX-Request to load a part of a Webpage, the request is handled by a framework, which delivers the content. After that, I use jquery to insert the delivered content into the DOM-Tree. So far, so good.

But I use background-images for links in the delivered content, which are generated while processing the AJAX-Request. Normally I would place the path to the background-image into a style-attribute in the link-tags, what works perfectly, until I want to use pseudo-classes for i.e. :hover (you know, to display an alternative image while the mouse hovers) The solution would be to create a custom CSS-file, which will be inserted into the HTML-Head, but until it is an AJAX-Request, the HTML-Head is already sent.

Do you have any idea, how to attach CSS-properties to links, which will be generated on AJAX-Call-Time?

A: 

not possible with inline style.

as s jones says, you can have the style in your existing CSS and it should pick it up.

the other option is to do it using jquery..

$('div.ajax a').hover(function(){$(this).css('color','red')});
Moin Zaman
a) Hover takes two functions, not one, unless its the same function over and over again (not in this case I believe) b) Javascript is *really* not needed here, CSS is almost always sufficient.
Yi Jiang