0
<apex:page sidebar="false">
  <script src="{!URLFOR($Resource.iVol_Resources, '/js/jquery_latest.js')}"></script>
  <script src="{!URLFOR($Resource.iVol_Resources, '/js/jquery-ui-git.js')}"></script>
  <script type="text/javascript"/>
  <script type="text/javascript">
    var $jq = jQuery.noConflict();
    jq$(document).ready(function()
    {
      jq$("#ton").click(function(){
        jq$("p").remove(".italic");
      });
    });
  </script>

  <body>
    <p>This is a paragraph in the div.</p>
    <p class="italic"><i>This is another paragraph in the div.</i></p>
    <p class="italic"><i>This is another paragraph in the div.</i></p>
    <button id="ton">Remove all p elements with class="italic"</button>
  </body>
</apex:page>

Hi, this is my code, but I implemented in Visualforce Page but its not working, no errors.

jQuery is stored in a static resource called ivol_resources.

Can anyone tell me why?

Regards,

Ganz

2 Answers 2

8

You've correctly reassigned jQuery to a different name using noConflict() but then you're not using the same name in your code! You need to use $jq not jq$:

<script type="text/javascript">
  var $jq = jQuery.noConflict();
  $jq(document).ready(function()
  {
    $jq("#ton").click(function(){
      $jq("p").remove(".italic");
    });
  });
0

Why not just do

<script type="text/javascript">
var $jq = jQuery.noConflict();
jq$(document).ready(function() {
      jq$("#ton").click(function(){
          jq$("p.italic").remove();
      });
});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .