1

需要用图像、按钮替换 Read More... 和 Read Less...。

$("a", $(this).parent()).text($(this).is(':visible') ? 'Read More...' : 'Read Less...');

我试过

$("a", $(this).parent()).text($(this).is(':visible') ? '<img src=images/testeon.jpg>' : '<img src=images/testeoff.jpg>');

但它显示了 src url

4

2 回答 2

2

尝试;

$("a", $(this).parent()).html($(this).is(':visible') ? '<img src="images/testeon.jpg">' : '<img src="images/testeoff.jpg">');
于 2013-10-11T09:30:29.557 回答
0

您可以围绕要替换的内容设置一个容器,然后用jQuery 的 .html() 函数替换其内容

这是一个例子

HTML:

<a id="myLink" href="javascript:insertImage();">read more..</a>

JS:

function insertImage()
{
    $("#myLink").html("<img src='http://3.bp.blogspot.com/--Fh64MyRDt0/T3XxC6ZVirI/AAAAAAAAJPo/WqHgsEZ7M8Q/s1600/image.php.jpg' />");
}

这将用给定的图像标签替换链接的内容(“阅读更多..”)。

于 2013-10-11T09:40:56.780 回答