Solved

jquery: How do I add a class to the td holding my input field?

Posted on 2010-08-18
1
277 Views
Last Modified: 2013-11-11
Hi,

I am trying to add a class to the <td> that is holding my span and input field but I can only seem to add the class to the span tag that is holding the input field.

the form is like this:
<td><span><Input/></span></td>

I am using Jquery, please modify the code below.

Thanks.
$(document).ready(function(){
$(".orderQty span INPUT").change(function(){
  
         if($(this).val() > 0 ) {
         
           $(this).parent().addClass("selected");
           
        
        } else {
            $(this).parent().removeClass("selected");
        }
});



-----------------------------------------------------------

<td class="orderQty"><span dir="none">
<input name="ctl00$m$g_7279058e_e51a_4bdc_bae0_cf09ae6c9811$ff10_1$ctl00$ctl00$TextField" type="text" value="0" id="ctl00_m_g_7279058e_e51a_4bdc_bae0_cf09ae6c9811_ff10_1_ctl00_ctl00_TextField" title="OrderQty" class="ms-input" Size="11" style="ime-mode:inactive;" /><br></span></td>

Open in new window

0
Comment
Question by:Solutionabc
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33465883
Use : $(this).parents("td").addClass("selected");
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question