Jump to content

jquery $(obj).whatever is not a function error...


RIRedinPA

Recommended Posts

I'm trying to just toggle a couple of objects between hide and show based on their current state but I keep running into the same error message, whether I try $(item).css('display') or $(item).is(':hidden'), I keep getting the (item).x is not a function... (where item is a variable, not a string), however I get the same error message when I hard code a string in there.

 

Here's the relevant jquery code

 


//...code above...

$('.clickme').click(function() {
					//make an array of class names 
					var myClasses = this.className.split(" ");
					//get last class name
					var showThis = "#" + myClasses[myClasses.length-1];
					//toggle
					if ((showThis).is(':hidden')) {
						$(showThis).slideDown();
					} else {
						$(showThis).slideUp();
					}
				});

 

 

relevant html stuff

 


<div id="resultsbox">

		<ul>
			<li class="tablerow_1">
				<p class="designator shop"> </p>
				<p class="itemname clickme fileinfo_1" onmouseover="cursorIn();" onmouseout="cursorOut();">GI_Item0003</p>
				<p class="priority">
					<?php
						for ($s=0; $s<3; $s++) { 	
							print "<img src=\"images/star.png\" width=\"10\">";
						} 
					?>
				</p>
				<p class="beauty"><img src="images/checkmark.png"></p>
				<p class="product"><img src="images/checkmark.png"></p>
				<p class="active"><input type="checkbox" name="id_active"></p>
				<p class="complete"><input type="checkbox" name="id_complete"></p>
				<p class="artpending"><img src="images/checkmark.png"></p>
				<p class="description">Words words words words words</p>
				<p class="swatch">No</p>
				<p class="livedate">06/01/2010</p>
				<p class="status">
					<select name="status">
						<option value="production">Production</option>
						<option value="admin">In Admin</option>
						<option value="live">Live</option>
						<option value="hold">On Hold</option>
					</select>
				</p>
				<p class="designer">Amy</p>
			</li>

			<li>
				<p class="hideme" id="fileinfo_1">This is where the file path will go</p>
			</li>

 

The code will return fileinfo_1 for the class to show, but it goes no further than that. I'm assuming jquery is not recognizing the object but why?

 

Thanks

 

Sorry, spotted it now.

 

Have you tried alerting the value of "showThis" just before the IF condition to ensure it's what you expect?

 

Yes, showThis comes back as "fileinfo_1" and so, in theory, when concactenated as "#" + showThis should be read as "#fileinfo_1" and point to the correct <p> which is hidden...right? Could it be because I have a class and id in the target <p> that is causing the error? (I actually don't think so but am frustrated at this point and just throwing crap against a wall to see if anything sticks) : D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.