javascript - 动态组合图像和文本并使整个 div 用作超链接

标签 javascript html ruby-on-rails css

一图胜千言:

问题:

图文如何排版才能整体起到 anchor 的作用?

alt text

最佳答案

制作你的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";
});

关于javascript - 动态组合图像和文本并使整个 div 用作超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4357205/

相关文章:

javascript - 如何为子窗口设置父窗口值?

javascript - tbody 无法在 jquery 中工作

javascript - jquery中的一个div两个函数

ruby-on-rails - 带有 RSPEC 错误的 Controller 测试未实现

javascript - 通过单击类里面的图像来更改图像

javascript - 函数前面的感叹号有什么作用?

javascript - d3.js : Want to understand the concept of applying individual properties to elements via a single command

css - 如何分隔 Bootstrap 标签组件?

ruby-on-rails - Rails select_tag 不会访问 belongs_to 关系

ruby-on-rails - Jruby - 类型错误 : illegal access on 'clone'