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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.