Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery selector not working while javascript DOM works fine
    text
    copied!<p>I am having troubles using JQuery to select the correct element. Using javascript DOM is working fine, but with JQuery I can not seem to get the correct element...</p> <p>This is working fine (the 'medium' length is 1, the 'small' length is 0) :</p> <pre><code>var medium = document.getElementById("Ribbon.Documents.WorkflowButtons.Workflow" + button + "-Medium"); var small = document.getElementById("Ribbon.Documents.WorkflowButtons.Workflow" + button + "-Small"); alert("Medium: " + jQuery(medium).length + " - Small: " + jQuery(small).length + " - State: " + workflowButtonState); </code></pre> <p>While this is not working (both lengths are equal to 0, which is not correct):</p> <pre><code>var medium = jQuery("#Ribbon.Documents.WorkflowButtons.Workflow" + button + "-Medium"); var small = jQuery("#Ribbon.Documents.WorkflowButtons.Workflow" + button + "-Small"); alert("Medium: " + jQuery(medium).length + " - Small: " + jQuery(small).length + " - State: " + workflowButtonState); </code></pre> <p>Another not working example is when using .html()</p> <p>Working (returns the html):</p> <pre><code>var button = document.getElementById("Ribbon.Documents.WorkflowButtons.Workflow" + buttonId + "-" + state); $(button).css("display", "none"); alert($(button).html()); </code></pre> <p>Not working (.html() return NULL)</p> <pre><code>var button = $("#Ribbon.Documents.WorkflowButtons.Workflow" + buttonId + "-" + state); $(button).css("display", "none"); alert($(button).html()); </code></pre> <p>Any idea why this is happening? I am executing this on the same page. So the same HTML elements etc. results should be the same, no ?</p> <p>I have verified the "document.readyState" being equal to "complete"</p> <p>PS: I have used two syntaxes: jQuery and $. This was to make sure there were no other issues.</p> <p>Thanks ! </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