开发者

combine image and text on the fly and make whole div works as an hypelink

A picture worth thousands of words:

Question:

How to layout the image and text so they can work as an anchor as开发者_StackOverflow社区 a whole?

combine image and text on the fly and make whole div works as an hypelink


make your html

var varhtml="<div id="somid">// give background url as image
text goes here
</div>"

('#parentHtmlid').append(varhtml); or
('#parentHtmlid').html(varhtml); if you have place holder

$('#someid').live('click', function() { // as this id added at run time use live in document.ready//
   location.href="http://yoururl";
});


Create a parent element for both the image and the text, with position: relative. Each of its children should be position: absolute, with appropriate top/bottom left/right to line things up the way you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜