Call a jquery function on a variable - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:text

Description

Call a jquery function on a variable

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//w  w  w  .j  a  v  a  2 s  .c o m

var comp_id = $.trim($("div.component_id").text()).replace(/^'|'$/g, '');
jQuery(comp_id).text('found');

    });

      </script> 
 </head> 
 <body> 
  <div class="component_id">
    '#test1' 
  </div> 
  <div id="test1"></div>  
 </body>
</html>

Related Tutorials