Hi Paul. I'm also looking for help to convert a jQuery function to pure JavaScript. Here is the jQuery. It's for use on a SharePoint Web Part Page. Apparently it works. I'd like to use pure JavaScript if possible rather than load the jQuery library. Thanks.

Hi Paul. I'm also looking for help to convert a jQuery function to pure JavaScript. Here is the jQuery. It's for use on a SharePoint Web Part Page. Apparently it works. I'd like to use pure JavaScript if possible rather than load the jQuery library. Thanks.

Paul ... thanks so much. I tried example #1 and #3 and they would load. In example #1, I changed the comma at the end of the first line to a semicolon. Do you see any other errors?

In example #3, I corrected the word Array on the 2nd line, but it would not load either. Unfortunately, SharePoint doesn't provide any error messages for the JavaScript. Any further ideas? Thank you so much for taking a stab at it.

Paul_Wilkins
—
2012-10-25T06:58:00Z —
#9

dugutigi said:

Paul ... thanks so much. I tried example #1 and #3 and they would load. In example #1, I changed the comma at the end of the first line to a semicolon. Do you see any other errors?

That is not an error. The following lines of code do the same job.

var linksToUnlink = document.querySelectorAll('[href="###"]');
var i;

var linksToUnlink = document.querySelectorAll('[href="###"]'),
i;

The second sample of code has a larger benefit in that it doesn't give the impression that multiple variable statements are okay, and serves to reinforce that variables should be declared in the one place from the start of function or the code.

dugutigi said:

In example #3, I corrected the word Array on the 2nd line, but it would not load either.

JavaScript has several pre-defined global objects, some that you may recognise and some that you don't seem to recognise as of yet.These pre-defined global objects are: [Array, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean"]Boolean, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date"]Date, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function"]Function, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Iterator"]Iterator, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"]Number, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"]Object, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp"]RegExp, [URL="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"]String](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array)

dugutigi said:

Unfortunately, SharePoint doesn't provide any error messages for the JavaScript. Any further ideas? Thank you so much for taking a stab at it.

I hope that you at some stage learn how to control SharePoint as well.