Solved

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

Posted on 2010-08-18
1
283 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

730 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