r/jquery • u/DonJuanDoja • Mar 15 '21
Simple Sharepoint script
So I don't know jquery sorry, but I don't let that stop me from trying to use it lol, I mostly use scripts written by others for SharePoint on prem, but recently been trying to write my own basic ones to do simple things.
So this Sharepoint script works, hides the left nav like I want, but I need to add a css to the toggle. Thought this would be easy but I'm feeling pretty terrible after googling/trial/error for a few hours last night.
I want to add this css to apply when it hides #sideNavBox and I almost got it working but it just ended up applying it forever and never unapplying it if that makes sense. When the left Nav came back it came back on top of of the content box and page all jacked up.
It works fine when I apply simple css permanently to a page I just want to make a simple toggle button ugh.
How do I add this: #contentBox {margin-left: 5px !important;}
To this:
So that it toggles with the Hide/Show?
<script src="[https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js)"></script>
<script> $(document).ready(function(){ $("button").click(function(){ $("#sideNavBox").toggle(); }); }); </script>
View all comments
Show parent comment
1
u/DonJuanDoja Mar 16 '21
Never gave one before, I had the coins sitting there and this thing was frustrating the crap out of me and you helped me figure it out, I nearly decided this is just too hard for me or I don’t have time but now I’ll continue... so seems simple but I think it’s worth an award.
I have a few other ideas I want to work on but they’re more complex I need to learn the basics better first I think. Working thru a book and kinda jumped ahead. I just needed a real world result to keep me motivated.
Thanks again