0

Insert href link on existing text: abc, part of a DIV ID: wpfunc01 on a SPS2013 List page. I guess this can be achieved via Jquery.

Please assist with the complete code to insert href on existing text: abc

1 Answer 1

0

I got the solution, here is it that may help others in the community -

In the below code, I have modified the TEXT Value: ALL with the same value and added Hyperlink.

<script type="text/javascript">

// Check the main container is ready
$('#WebPartWPQ2').ready(function(){
    // Get each div
    $('#scriptPagingWPQ2').each(function(){
        // Get the content
        var str = $(this).html();
        // Set the regex string
        var regex = /All/ig
        // Replace plain text links by hyperlinks
        var replaced_text = str.replace(regex, "<a href='http://www.example.com' target='_blank'>All</a>");
        // Echo link
        $(this).html(replaced_text);
    });
});


</script> 
1
  • doesnt allows to mark answer for 2 days.
    – Jason
    Commented Jun 7, 2016 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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