Solved

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

Posted on 2010-08-18
1
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

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

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

695 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