Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery 1.7 checkbox and checked
    text
    copied!<p>While I use this </p> <pre><code> jQuery($("select[id='Input"+id+"OdbcParamsId']")).toggle(); </code></pre> <p>and I toggle the select box. I try to check also after the loading of the page if a checkbox is really checked: One option:</p> <pre><code> if($( "checkbox[id='Input_" + id+"Isquery_'").attr('checked', 'checked')){....} </code></pre> <p>Second option :</p> <pre><code>if $( "checkbox[id='Input_" + id+"Isquery_'").is(':checked')) {....} </code></pre> <p>However both do not work. Despite the way I typed it is from fellows on google. Then the working option for me is :</p> <pre><code>$( "#Input_" + id+"Isquery").is(":checked") {...} </code></pre> <p>And the most bizzare now is that it doesn't fire always the event correctly the following final code of mine:</p> <pre><code>alert($( "#Input_" + id+"Isquery").is(":checked")); if (!$( "#Input_" + id+"Isquery").is(":checked")){ jQuery($("select[id='Input"+id+"OdbcParamsId']")).toggle(); } </code></pre> <p>And as you see while the event toggle is really working, the selector no. I am a very newbie at JQuery, and I don't understand why. Do we have to use different selectors for different events and methods ? Please somebody explain. Thank you. <strong>[EDIT]:</strong> ** [HTML CODE] **</p> <pre><code>&lt;td&gt;&lt;div class="input checkbox"&gt;&lt;input type="hidden" name="data[Input_41][isquery]" id="Input_41Isquery_" value="0"/&gt;&lt;input type="checkbox" name="data[Input_41][isquery]" class="chks" onclick="jqOnOffInputFormDbToggle(41)" options="True False (choose one)" value="1" id="Input_41Isquery"/&gt;&lt;label for="Input_41Isquery"&gt;&lt;/label&gt;&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="data[Input][41][odbc_params_id]" id="Input41OdbcParamsId"&gt; &lt;option value=""&gt;(choose)&lt;/option&gt; &lt;option value="52"&gt;PGSQL1&lt;/option&gt; &lt;/select&gt;&lt;/div&gt;&lt;/td&gt; </code></pre> <p>I have to say that replacing toggle() with show/hide really works the result. But the thing with the selector is a bit of awkward mystery for me</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload