0

I need to implement a simple show/hide div when a user clicks on a specific area of a map in sharepoint. The following code works perfectly in all browsers, but when i paste it exactly as is in the HTML editor window inside my webpart, the show/hide functionality becomes unresponsive.

I have read i need to add the jquery file into the master page, but i do not have access to do so, i also tried uploading the jquery file into the Style Layout page, but also gives me access denied even though i have full control of the site. So any suggestions on how to make this work would be great. My code is below.

<html>
<head>
<style>
a,img { border: none; }
.comb {display: none;}
</style>
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">  </script>

</head>
<body>
<map name="FPMap0" id="FPMap0">
<area item="first" href="#" shape="polygon" coords="347, 79, 349, 201, 449, 248, 540, 204, 541, 82, 448, 34" />
<area item="second" href="#" shape="polygon" coords="560, 81, 562, 206, 660, 255, 756, 208, 758, 81, 659, 31" />
</map>

<img width="1000" height="667" src="main.png" usemap="#FPMap0" alt=""/>​

<div class="comb" id="first">t1</div>
<div class="comb" id="second">t2</div>

<script>
$('area').on('click',function() {
$('.comb').hide();
$('#' + $(this).attr('item')).show();
});
</script>
</body>
</html>
  • Are you using a content editor webpart? What version of SharePoint? – Bryan Mathews May 20 '15 at 2:03
  • Have you tried debugging to see whether you're getting errors at all? Open IE, press F12 to open the Developer Tools pane, click the Debugger tab and then go to the page/refresh the page. Check for any errors. – Submits May 20 '15 at 10:42
0

If you are using SharePoint 2010, SharePoint does special formatting to content editor web-parts. You have two options

  1. Use an HTML Form Webpart. SharePoint will not modify the contents of this webpart and it will work like a content editor webpart working in SharePoint 2007 and prior.
  2. Use a .txt file which you store your content in and link to it with the content editor webpart. I prefer this option because it allows you to re-use the content if you need to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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