如何使用jquery在div内添加文本链接? [英] how to add text link inside a div using jquery?
本文介绍了如何使用jquery在div内添加文本链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 div 中放置一些文本作为链接.
I want to place some text as link inside a div.
例如,我想在 class-id 为my-链接".
For example, I want to place text 'Google' with hyperlink <a href="http://www.google.com"
inside a div having class-id as "my-link".
如何使用 jquery 或 javascript 完成此操作?
How can this be done using jquery or javascript?
推荐答案
Class 和 ID 不一样.
Class and ID is not the same.
如果 ID 试试这个:
If ID try this:
$('#my-link').html('<a href="http://www.google.com">Google</a>');
演示 带 ID
如果班级试试这个:
$('.my-link').html('<a href="http://www.google.com">Google</a>');
^
演示 带类
这篇关于如何使用jquery在div内添加文本链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文