Reputation: 37
Need replace Read More... and Read Less... with images, buttons.
$("a", $(this).parent()).text($(this).is(':visible') ? 'Read More...' : 'Read Less...');
I tried
$("a", $(this).parent()).text($(this).is(':visible') ? '<img src=images/testeon.jpg>' : '<img src=images/testeoff.jpg>');
But it shows the src url
Upvotes: 1
Views: 102
Reputation: 21137
You could set a container around of what you want to replace, then just replace its content with jQuery's .html() function
Here is an example
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' />");
}
This will replace the content of the link ("read more..") with the given image tag.
Upvotes: 0
Reputation: 21386
Try;
$("a", $(this).parent()).html($(this).is(':visible') ? '<img src="images/testeon.jpg">' : '<img src="images/testeoff.jpg">');
Upvotes: 2