Solved

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

Posted on 2010-08-18
1
273 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
Comment Utility
Use : $(this).parents("td").addClass("selected");
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now