0

I want to disable the hyperlink for a specific class part of Site Feeds in SharePoint 2013.

I`m using Jquery to do the same, but it is not working for me. Code for reference

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script type="text/javascript">



 var location= $('.ms-microfeed-userName ms-textLarge ms-subtleLink').attr("href");
 $(".ms-microfeed-userName ms-textLarge ms-subtleLink").removeAttr('href');
 $('ul').addClass('expanded');
 $('ul.expanded').fadeIn(300);
 $(".ms-microfeed-userName ms-textLarge ms-subtleLink").attr("href", location);


 </script>
1
  • The code seems to not at all remove a hyperlink, you should really just need the second jQuery line, but with my alterations from the answer below Jul 19, 2016 at 7:27

1 Answer 1

0

There is a mistake when you're selecting the elements using multiple classes. It should be like this

$('.ms-microfeed-userName, .ms-textLarge, .ms-subtleLink').attr("href"); 

Instead of $('.ms-microfeed-userName ms-textLarge ms-subtleLink').attr("href"); 

10
  • That's also wrong, it should be $('.ms-microfeed-userName.ms-textLarge.ms-subtleLink') since the ancor tag has al three classes on it Jul 19, 2016 at 6:27
  • @Robert, I tried with both options: code 1: <script src="ajax.googleapis.com/ajax/libs/jquery/1.12.3/…> <script type="text/javascript"> $('.ms-microfeed-userName.ms-textLarge.ms-subtleLink').click(function () {return false;}); </script> Code 2: <script src="ajax.googleapis.com/ajax/libs/jquery/1.12.3/…> <script type="text/javascript"> $('.ms-microfeed-userName.ms-textLarge.ms-subtleLink').attr("href"); </script> Still the same
    – Jason
    Jul 19, 2016 at 6:42
  • @robert howz that supposed to work, how will jquery understand if the classes are not separated.. Jason did you try my solution Jul 19, 2016 at 6:54
  • @ThatThatGuy are you serious? The element in question is ONE a-tag with three classes on it, so the pattern I gave is how you select it in CSS and hence in jQUery selector Jul 19, 2016 at 6:55
  • @jason do check if you're able to select the elements with multiple classes Jul 19, 2016 at 6:55

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.