Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have been trying to edit links within lists to change their overall functionality, but have had no luck with changing any property of the links' functions. The properties I have tried to change thus far are the text-decoration and the href destination. This is my code for attempting to change the href destination.

$(".ms-vb2 a, .ms-vb-title a, .ms-vb-user a").each(function () {
    var itemText = $(this).text();
    $(this).html("<a href='http://www.google.com'>" + itemText + '</a>');
});

The idea is that I want all of the links to hold the text of the original SharePoint list items, but to link me to something other than a list actions menu. An additional note: I have been able to change text properties, such as font color, but not link properties, such as href.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
$(".ms-vb2 a, .ms-vb-title a, .ms-vb-user a").each(function () {

    //Cache the current A tag.
    var currentA = $(this);

    //Use any one of the following to remove the old href.
    currentA.prop("href",null);
    currentA.removeAttr("href");
    currentA.attr("href","");

    //Use this to add your new href to the same link.
    currentA.attr("href","http://www.google.com");

});
share|improve this answer
    
I've had some success with this, so I'll start here and keep messing with it. Thanks for the help! –  Randy Grizzle Sep 1 '12 at 14:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.