Sunday, 15 May 2011

html - Jquery Accessing Heavily Nested Input -


I am trying to use an input that is & lt; Span & gt; & Lt; / Span & gt; and & lt; P & gt; & Lt; / P & gt; . The way I'm nesting it can not be changed, so that only one thing I can do is try to find a way to access it. Below is my code nested (can not be changed). Inb4 My JQuery is enabled I have already made some test alerts.

  & lt; Div id = "chargeRequest" & gt; & Lt; P & gt; Chargable Requests - If the filled in selected section below & lt; Br> & Lt; Span class = "wpcf7-form-control-wrap checkbox -397" & gt; & Lt; Span class = "wpcf7-form-control wpcf7-checkbox" & gt; & Lt; Span class = "wpcf7-list-item first last" & gt; & Lt; Input type = "checkbox" name = "checkbox-397 []" value = "yes" & gt; & Lt; Span class = "wpcf7-list-item-label" & gt; Yes & lt; / Span & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt; / P & gt; & Lt; / Div & gt;  

attempt

I am trying to give a simple warning to JQuery when the check box is checked, but I can not access it I am here. Below I've tried everything

The first example was going out of the outermost div and seeing that it could be found and inputted with the checked property. There was nothing like this

  if ($ ('$ chargeRequest'). Search ('input') .pr. ('Check') {warning ('test'); }  

The second attempt was to try to use the Span class one layer and then look for an input. Once it was found that the AHD has been investigated it was examined. Nopthign also happened here.

  If ($ ('. Checkbox -397'). ('Input')) Find (if (this. ('Check')) {Warning ('test');}}  

The third attempt has tried to make me an unsubstantiated and nesting chain. It does not appear in Nesting under 2 attempts.

  ('# Chargerivity', & gt; P & gt; Span & gt; Span & gt; Input: Check ')) {Warning (' Test ');}} If ($ (' $ charge '& gt; P & gt; Span & gt; Period & gt; Input '). (': Check ')) {Warning (' Test ');}}  

The method also tried .prop () and it has & gt;

/ div>

Your first attempt should be to work only, to remove the location from the id.

should be

id = "chargeRequest" & gt; Additionally, you can select the input like this:

  if ($ (' # ChargeRequest input ') .prop (' check ')) {warning (' test '); 
  $ ('input'). Click (function () (if ($ ('(# $ charge charge)') .prop ('check')) {warning ('test');}})  
  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Div id = "chargeRequest" & gt; & Lt; P & gt; Chargable Requests - If the filled in selected section below & lt; Br> & Lt; Span class = "wpcf7-form-control-wrap checkbox -397" & gt; & Lt; Span class = "wpcf7-form-control wpcf7-checkbox" & gt; & Lt; Span class = "wpcf7-list-item first last" & gt; & Lt; Input type = "checkbox" name = "checkbox-397 []" value = "yes" /> & Lt; Span class = "wpcf7-list-item-label" & gt; Yes & lt; / Span & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt; / P & gt; & Lt; / Div & gt;  


No comments:

Post a Comment