Title: jquery noconflict issue
Last modified: August 24, 2016

---

# jquery noconflict issue

 *  [stephenblender](https://wordpress.org/support/users/stephenblender/)
 * (@stephenblender)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/jquery-noconflict-issue/)
 * Thanks for the plugin. Elegant use of shortcodes. Still waiting for my first 
   confirmed session, but thought I would share this issue I had to resolve. Not
   sure whether to blame the plugin or my theme… 😉
 * I was getting a javascript error not recognizing the jquery ‘$’ symbol. A little
   googling suggested the issue was that wp was including jquery in noconflict mode
   meaning you had to use the full ‘jQuery()’ and not the short form ‘$()’.
 * Time was short so after trying a couple of solutions without changing the plugin
   code I gave up and modified the plugin code, updated below. Only change was the
   line after my comment starting ‘// stephen … ‘ where I changed the ‘$(‘ to a ‘
   jQuery(‘ .
 * Likely there is a better solution.
 *     ```
       function head_javascript() {
       	/* ----------------------------------------------------
       		echo out the required javascript
       	*/
       	echo '
       	<!-- Pre-flight to test for Content Experiments: -->
       	<script>
   
       	// Object.keys polyfill for IE8 and below
       	if (!Object.keys) Object.keys = function(o) {
       		if (o !== Object(o))
       			throw new TypeError("Object.keys called on a non-object");
       		var k=[],p;
       		for (p in o) if (Object.prototype.hasOwnProperty.call(o,p)) k.push(p);
       		return k;
       	}
   
       		var content_experiment = {
       			id: "",
       			variant_count:0,
       			selected: 1
       		}
   
       		// stephen - changed $ to jQuery to resolve noconflict error
       		jQuery(document).ready(function() {
       			var ex_list = {};
       			$( ".contentexperimentvariant" ).each(
       				function( ) {
       					var v_id = $( this ).attr("data-contentexperimentid");
       					console.log(v_id);
       ...
       ```
   
 * [https://wordpress.org/plugins/simple-content-experiments/](https://wordpress.org/plugins/simple-content-experiments/)

The topic ‘jquery noconflict issue’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-content-experiments_0077f5.
   svg)
 * [Simple Content Experiments](https://wordpress.org/plugins/simple-content-experiments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-content-experiments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-content-experiments/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-content-experiments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-content-experiments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-content-experiments/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [stephenblender](https://wordpress.org/support/users/stephenblender/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/jquery-noconflict-issue/)
 * Status: not resolved